found an uncontrollable warning

This commit is contained in:
Bill Currie 2010-02-20 12:01:49 +00:00 committed by Jeff Teunissen
parent 6a63263c94
commit 56d01ce267
4 changed files with 11 additions and 1 deletions

View file

@ -281,6 +281,9 @@ interface for a class.
.B precedence
Emit a warning when potentially ambiguous logic is used without parentheses.
.TP
.B redeclared
Emit a warning when a local variable is redeclared.
.TP
.B traditional
Emit a warning when code that should be an error is allowed by traditional
\fBqcc\fP.

View file

@ -58,6 +58,7 @@ typedef struct {
qboolean precedence; // Warn on precedence issues
qboolean initializer; // Warn on excessive initializer elements
qboolean unimplemented; // Warn on unimplemented class methods
qboolean redeclared; // Warn on redeclared local variables
} warn_options_t;
typedef struct {

View file

@ -217,6 +217,7 @@ warning_usage (void)
" interface.\n"
" none Turn off all warnings.\n"
" [no-]precedence Warn about potentially ambiguous logic.\n"
" [no-]redeclared Warn about redeclared local variables.\n"
" [no-]traditional Warn about bad code that qcc allowed.\n"
" [no-]undef-function Warn about calling a yet to be defined\n"
" function.\n"
@ -276,6 +277,7 @@ DecodeArgs (int argc, char **argv)
options.warnings.precedence = true;
options.warnings.initializer = true;
options.warnings.unimplemented = true;
options.warnings.redeclared = true;
options.single_cpp = true;
options.save_temps = false;
@ -417,6 +419,7 @@ DecodeArgs (int argc, char **argv)
options.warnings.precedence = true;
options.warnings.initializer = true;
options.warnings.unimplemented = true;
options.warnings.redeclared = true;
} else if (!(strcasecmp (temp, "none"))) {
options.warnings.cow = false;
options.warnings.undefined_function = false;
@ -430,6 +433,7 @@ DecodeArgs (int argc, char **argv)
options.warnings.precedence = false;
options.warnings.initializer = false;
options.warnings.unimplemented = false;
options.warnings.redeclared = false;
} else {
qboolean flag = true;
@ -453,6 +457,8 @@ DecodeArgs (int argc, char **argv)
options.warnings.interface_check = flag;
} else if (!strcasecmp (temp, "precedence")) {
options.warnings.precedence = flag;
} else if (!strcasecmp (temp, "redeclared")) {
options.warnings.redeclared = flag;
} else if (!strcasecmp (temp, "traditional")) {
options.warnings.traditional = flag;
} else if (!strcasecmp (temp, "undef-function")) {

View file

@ -1733,7 +1733,7 @@ create_def (type_t *type, const char *name, scope_t *scope,
warning (0, "local %s shadows param %s", name,
def->name);
}
if (def->scope == scope) {
if (def->scope == scope && options.warnings.redeclared) {
expr_t e;
warning (0, "local %s redeclared", name);
e.file = def->file;