make integer constant division warnings optional

This commit is contained in:
Bill Currie 2001-12-12 22:00:42 +00:00
parent 2db08923e8
commit 112f74a357
3 changed files with 11 additions and 2 deletions

View file

@ -603,6 +603,7 @@ typedef struct {
qboolean undefined_function; // Warn on undefined function use
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
} warn_options_t;
typedef struct {

View file

@ -736,7 +736,8 @@ do_op_integer (int op, expr_t *e1, expr_t *e2)
e1->e.integer_val *= i2;
break;
case '/':
warning (e2, "%d / %d == %d", i1, i2, i1 / i2);
if (options.warnings.integer_divide)
warning (e2, "%d / %d == %d", i1, i2, i1 / i2);
e1->e.integer_val /= i2;
break;
case '&':
@ -812,7 +813,8 @@ do_op_uinteger (int op, expr_t *e1, expr_t *e2)
e1->e.uinteger_val *= i2;
break;
case '/':
warning (e2, "%d / %d == %d", i1, i2, i1 / i2);
if (options.warnings.integer_divide)
warning (e2, "%d / %d == %d", i1, i2, i1 / i2);
e1->e.uinteger_val /= i2;
break;
case '&':

View file

@ -793,11 +793,13 @@ DecodeArgs (int argc, char **argv)
options.warnings.undefined_function = true;
options.warnings.uninited_variable = true;
options.warnings.vararg_integer = true;
options.warnings.integer_divide = true;
} else if (!(strcasecmp (temp, "none"))) {
options.warnings.cow = false;
options.warnings.undefined_function = false;
options.warnings.uninited_variable = false;
options.warnings.vararg_integer = false;
options.warnings.integer_divide = false;
} else if (!(strcasecmp (temp, "cow"))) {
options.warnings.cow = true;
} else if (!(strcasecmp (temp, "no-cow"))) {
@ -818,6 +820,10 @@ DecodeArgs (int argc, char **argv)
options.warnings.vararg_integer = true;
} else if (!(strcasecmp (temp, "no-vararg-integer"))) {
options.warnings.vararg_integer = false;
} else if (!(strcasecmp (temp, "integer-divide"))) {
options.warnings.integer_divide = true;
} else if (!(strcasecmp (temp, "no-integer-divide"))) {
options.warnings.integer_divide = false;
}
temp = strtok (NULL, ",");
}