From 5e6b25c917a2f71a9c92facc84665036cf677a3e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 29 Jul 2003 18:31:12 +0000 Subject: [PATCH] add interface-check warning option. defaults off --- tools/qfcc/doc/man/qfcc.1 | 4 ++++ tools/qfcc/include/options.h | 1 + tools/qfcc/source/class.c | 10 ++++++---- tools/qfcc/source/options.c | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/qfcc/doc/man/qfcc.1 b/tools/qfcc/doc/man/qfcc.1 index 7a797b595..9c64ab0fb 100644 --- a/tools/qfcc/doc/man/qfcc.1 +++ b/tools/qfcc/doc/man/qfcc.1 @@ -159,6 +159,10 @@ Emit a warning when the source assigns a value to a named constant. See the description of the \fBcow\fP code option above for a description of what this means. .TP +.B interface\-check +Emit a warning when a method is declared in an implementation but not in the +interface for a class. +.TP .B undef\-function Emit a warning when a function is called, but has not yet been defined. .TP diff --git a/tools/qfcc/include/options.h b/tools/qfcc/include/options.h index ab02e19ea..2692a5d5f 100644 --- a/tools/qfcc/include/options.h +++ b/tools/qfcc/include/options.h @@ -47,6 +47,7 @@ typedef struct { qboolean uninited_variable; // Warn on use of uninitialized vars qboolean vararg_integer; // Warn on passing an integer to vararg func qboolean integer_divide; // Warn on integer constant division + qboolean interface_check; // Warn for methods not in interface } warn_options_t; typedef struct { diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index 75473f15e..774423fcb 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -411,10 +411,12 @@ class_find_method (class_type_t *class_type, method_t *method) } sel = dstring_newstr (); selector_name (sel, (keywordarg_t *)method->selector); - warning (0, "%s method %s not in %s%s", - method->instance ? "instance" : "class", - sel->str, class_name, - category_name ? va (" (%s)", category_name) : ""); + if (options.warnings.interface_check) { + warning (0, "%s method %s not in %s%s", + method->instance ? "instance" : "class", + sel->str, class_name, + category_name ? va (" (%s)", category_name) : ""); + } dstring_delete (sel); return method; } diff --git a/tools/qfcc/source/options.c b/tools/qfcc/source/options.c index 5fbf04838..306f3fda8 100644 --- a/tools/qfcc/source/options.c +++ b/tools/qfcc/source/options.c @@ -307,6 +307,10 @@ DecodeArgs (int argc, char **argv) options.warnings.integer_divide = true; } else if (!(strcasecmp (temp, "no-integer-divide"))) { options.warnings.integer_divide = false; + } else if (!(strcasecmp (temp, "interface-check"))) { + options.warnings.interface_check = true; + } else if (!(strcasecmp (temp, "no-interface-check"))) { + options.warnings.interface_check = false; } temp = strtok (NULL, ","); }