diff options
-rw-r--r-- | gcc/ChangeLog | 27 | ||||
-rw-r--r-- | gcc/c-common.c | 15 | ||||
-rw-r--r-- | gcc/c-decl.c | 25 | ||||
-rw-r--r-- | gcc/c-format.c | 17 | ||||
-rw-r--r-- | gcc/c-lex.c | 10 | ||||
-rw-r--r-- | gcc/c-opts.c | 27 | ||||
-rw-r--r-- | gcc/c-parser.c | 5 | ||||
-rw-r--r-- | gcc/c-pragma.c | 6 | ||||
-rw-r--r-- | gcc/c-typeck.c | 13 | ||||
-rw-r--r-- | gcc/c.opt | 2 | ||||
-rw-r--r-- | gcc/flags.h | 5 | ||||
-rw-r--r-- | gcc/gcse.c | 12 | ||||
-rw-r--r-- | gcc/opts.c | 3 | ||||
-rw-r--r-- | gcc/stor-layout.c | 3 | ||||
-rw-r--r-- | gcc/toplev.c | 5 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 8 |
16 files changed, 109 insertions, 74 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d09ddeda84..256fbf5f289 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,30 @@ +2005-05-24 DJ Delorie <dj@redhat.com> + + * c-common.c (unsigned_conversion_warning): Move warning control + from if() to warning(OPT_*). + (c_common_truthvalue_conversion): Likewise. + (c_do_switch_warnings): Likewise. + * c-decl.c (diagnose_mismatched_decls): Likewise. + (diagnose_mismatched_decls): Likewise. + (define_label): Likewise. + (grokdeclarator): Likewise. + * c-format.c (check_format_info): Likewise. + * c-lex.c (interpret_integer): Likwise. + (lex_string): Likewise. + * c-opts.c (c_common_post_options): Likewise. + * c-parser.c (c_parser_unary_expression): Likewise. + * c-pragma.c (handle_pragma_redefine_extname): Likewise. + (handle_pragma_extern_prefix): Likewise. + * c-typeck.c (build_binary_op): Likewise. + * gcse.c (is_too_expensive): Likewise. + * opts.c (decode_options): Likewise. + * stor-layout.c (place_field): Likewise. + * tree-cfg.c (remove_bb): Likewise. + + * c.opt (-Wreturn-type): Add Var(warn_return_type). + * flags.h (warn_return_type): Remove. + * toplev.c (warn_return_type): Likewise. + 2005-05-24 Kelley Cook <kcook@gcc.gnu.org> * configure.ac: Don't use gcc_AC_C_LONG_LONG. Check for diff --git a/gcc/c-common.c b/gcc/c-common.c index c9027463795..17efd336e05 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -945,8 +945,9 @@ unsigned_conversion_warning (tree result, tree operand) if (!int_fits_type_p (operand, c_common_signed_type (type))) /* This detects cases like converting -129 or 256 to unsigned char. */ warning (0, "large integer implicitly truncated to unsigned type"); - else if (warn_conversion) - warning (0, "negative integer implicitly converted to unsigned type"); + else + warning (OPT_Wconversion, + "negative integer implicitly converted to unsigned type"); } } @@ -2470,8 +2471,9 @@ c_common_truthvalue_conversion (tree expr) break; case MODIFY_EXPR: - if (warn_parentheses && !TREE_NO_WARNING (expr)) - warning (0, "suggest parentheses around assignment used as truth value"); + if (!TREE_NO_WARNING (expr)) + warning (OPT_Wparentheses, + "suggest parentheses around assignment used as truth value"); break; default: @@ -3725,8 +3727,9 @@ c_do_switch_warnings (splay_tree cases, location_t switch_location, return; default_node = splay_tree_lookup (cases, (splay_tree_key) NULL); - if (warn_switch_default && !default_node) - warning (0, "%Hswitch missing default case", &switch_location); + if (!default_node) + warning (OPT_Wswitch_default, "%Hswitch missing default case", + &switch_location); /* If the switch expression was an enumerated type, check that exactly all enumeration literals are covered by the cases. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 8653d8f2b2d..efbd512d062 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1154,9 +1154,9 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, else if (TREE_PUBLIC (newdecl)) warning (0, "%Jbuilt-in function %qD declared as non-function", newdecl, newdecl); - else if (warn_shadow) - warning (0, "%Jdeclaration of %qD shadows a built-in function", - newdecl, newdecl); + else + warning (OPT_Wshadow, "%Jdeclaration of %qD shadows " + "a built-in function", newdecl, newdecl); return false; } @@ -1270,9 +1270,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, || (DECL_INITIAL (newdecl) && !TYPE_ARG_TYPES (TREE_TYPE (newdecl))))) { - if (warn_shadow) - warning (0, "%Jdeclaration of %qD shadows a built-in function", - newdecl, newdecl); + warning (OPT_Wshadow, "%Jdeclaration of %qD shadows " + "a built-in function", newdecl, newdecl); /* Discard the old built-in function. */ return false; } @@ -2543,9 +2542,9 @@ define_label (location_t location, tree name) /*invisible=*/false, /*nested=*/false); } - if (warn_traditional && !in_system_header && lookup_name (name)) - warning (0, "%Htraditional C lacks a separate namespace for labels, " - "identifier %qE conflicts", &location, name); + if (!in_system_header && lookup_name (name)) + warning (OPT_Wtraditional, "%Htraditional C lacks a separate namespace " + "for labels, identifier %qE conflicts", &location, name); nlist_se = XOBNEW (&parser_obstack, struct c_label_list); nlist_se->next = label_context_stack_se->labels_def; @@ -4271,8 +4270,9 @@ grokdeclarator (const struct c_declarator *declarator, them for noreturn functions. */ if (VOID_TYPE_P (type) && really_funcdef) pedwarn ("function definition has qualified void return type"); - else if (warn_return_type) - warning (0, "type qualifiers ignored on function return type"); + else + warning (OPT_Wreturn_type, + "type qualifiers ignored on function return type"); type = c_build_qualified_type (type, type_quals); } @@ -6079,7 +6079,8 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) #endif if (!in_system_header) - warning (OPT_Wold_style_definition, "%Jold-style function definition", fndecl); + warning (OPT_Wold_style_definition, "%Jold-style function definition", + fndecl); /* Match each formal parameter name with its declaration. Save each decl in the appropriate TREE_PURPOSE slot of the parmids chain. */ diff --git a/gcc/c-format.c b/gcc/c-format.c index daa071e61ab..f413e39d411 100644 --- a/gcc/c-format.c +++ b/gcc/c-format.c @@ -1140,8 +1140,8 @@ check_format_info (function_format_info *info, tree params) { /* For strftime-like formats, warn for not checking the format string; but there are no arguments to check. */ - if (warn_format_nonliteral) - warning (0, "format not a string literal, format string not checked"); + warning (OPT_Wformat_nonliteral, + "format not a string literal, format string not checked"); } else if (info->first_arg_num != 0) { @@ -1154,10 +1154,15 @@ check_format_info (function_format_info *info, tree params) params = TREE_CHAIN (params); ++arg_num; } - if (params == 0 && (warn_format_nonliteral || warn_format_security)) - warning (0, "format not a string literal and no format arguments"); - else if (warn_format_nonliteral) - warning (0, "format not a string literal, argument types not checked"); + if (params == 0 && warn_format_security) + warning (OPT_Wformat_security, + "format not a string literal and no format arguments"); + else if (params == 0 && warn_format_nonliteral) + warning (OPT_Wformat_nonliteral, + "format not a string literal and no format arguments"); + else + warning (OPT_Wformat_nonliteral, + "format not a string literal, argument types not checked"); } } diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 990d2bee455..052c3f69122 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -599,8 +599,9 @@ interpret_integer (const cpp_token *token, unsigned int flags) itk = itk_u; warning (0, "this decimal constant is unsigned only in ISO C90"); } - else if (warn_traditional) - warning (0, "this decimal constant would be unsigned in ISO C90"); + else + warning (OPT_Wtraditional, + "this decimal constant would be unsigned in ISO C90"); } } } @@ -763,8 +764,9 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) if (concats) strs = (cpp_string *) obstack_finish (&str_ob); - if (concats && !objc_string && warn_traditional && !in_system_header) - warning (0, "traditional C rejects string constant concatenation"); + if (concats && !objc_string && !in_system_header) + warning (OPT_Wtraditional, + "traditional C rejects string constant concatenation"); if ((c_lex_string_translate ? cpp_interpret_string : cpp_interpret_string_notranslate) diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 62fec1a124a..a79933359fe 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -979,18 +979,21 @@ c_common_post_options (const char **pfilename) /* Special format checking options don't work without -Wformat; warn if they are used. */ - if (warn_format_y2k && !warn_format) - warning (0, "-Wformat-y2k ignored without -Wformat"); - if (warn_format_extra_args && !warn_format) - warning (0, "-Wformat-extra-args ignored without -Wformat"); - if (warn_format_zero_length && !warn_format) - warning (0, "-Wformat-zero-length ignored without -Wformat"); - if (warn_format_nonliteral && !warn_format) - warning (0, "-Wformat-nonliteral ignored without -Wformat"); - if (warn_format_security && !warn_format) - warning (0, "-Wformat-security ignored without -Wformat"); - if (warn_missing_format_attribute && !warn_format) - warning (0, "-Wmissing-format-attribute ignored without -Wformat"); + if (!warn_format) + { + warning (OPT_Wformat_y2k, + "-Wformat-y2k ignored without -Wformat"); + warning (OPT_Wformat_extra_args, + "-Wformat-extra-args ignored without -Wformat"); + warning (OPT_Wformat_zero_length, + "-Wformat-zero-length ignored without -Wformat"); + warning (OPT_Wformat_nonliteral, + "-Wformat-nonliteral ignored without -Wformat"); + warning (OPT_Wformat_security, + "-Wformat-security ignored without -Wformat"); + warning (OPT_Wmissing_format_attribute, + "-Wmissing-format-attribute ignored without -Wformat"); + } /* C99 requires special handling of complex multiplication and division; -ffast-math and -fcx-limited-range are handled in process_options. */ diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 96bab469f41..04fffd1a23f 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -4518,8 +4518,9 @@ c_parser_unary_expression (c_parser *parser) return ret; case CPP_PLUS: c_parser_consume_token (parser); - if (!c_dialect_objc () && warn_traditional && !in_system_header) - warning (0, "traditional C rejects the unary plus operator"); + if (!c_dialect_objc () && !in_system_header) + warning (OPT_Wtraditional, + "traditional C rejects the unary plus operator"); return parser_build_unary_op (CONVERT_EXPR, c_parser_cast_expression (parser, NULL)); case CPP_MINUS: diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index be50856a442..f4801e87c06 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -418,7 +418,8 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) if (!flag_mudflap && !targetm.handle_pragma_redefine_extname) { if (warn_unknown_pragmas > in_system_header) - warning (0, "#pragma redefine_extname not supported on this target"); + warning (OPT_Wunknown_pragmas, + "#pragma redefine_extname not supported on this target"); return; } @@ -486,7 +487,8 @@ handle_pragma_extern_prefix (cpp_reader * ARG_UNUSED (dummy)) /* Note that the length includes the null terminator. */ pragma_extern_prefix = (TREE_STRING_LENGTH (prefix) > 1 ? prefix : NULL); else if (warn_unknown_pragmas > in_system_header) - warning (0, "#pragma extern_prefix not supported on this target"); + warning (OPT_Wunknown_pragmas, + "#pragma extern_prefix not supported on this target"); } /* Hook from the front ends to apply the results of one of the preceding diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 1911ae59332..00f701093ec 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -7523,8 +7523,8 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, case EXACT_DIV_EXPR: /* Floating point division by zero is a legitimate way to obtain infinities and NaNs. */ - if (warn_div_by_zero && skip_evaluation == 0 && integer_zerop (op1)) - warning (0, "division by zero"); + if (skip_evaluation == 0 && integer_zerop (op1)) + warning (OPT_Wdiv_by_zero, "division by zero"); if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE) @@ -7562,8 +7562,8 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, case TRUNC_MOD_EXPR: case FLOOR_MOD_EXPR: - if (warn_div_by_zero && skip_evaluation == 0 && integer_zerop (op1)) - warning (0, "division by zero"); + if (skip_evaluation == 0 && integer_zerop (op1)) + warning (OPT_Wdiv_by_zero, "division by zero"); if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) { @@ -7655,8 +7655,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, case EQ_EXPR: case NE_EXPR: - if (warn_float_equal && (code0 == REAL_TYPE || code1 == REAL_TYPE)) - warning (0, "comparing floating point with == or != is unsafe"); + if (code0 == REAL_TYPE || code1 == REAL_TYPE) + warning (OPT_Wfloat_equal, + "comparing floating point with == or != is unsafe"); /* Result of comparison is always int, but don't convert the args to int! */ build_type = integer_type_node; diff --git a/gcc/c.opt b/gcc/c.opt index d06ac94772e..a055216e706 100644 --- a/gcc/c.opt +++ b/gcc/c.opt @@ -339,7 +339,7 @@ C++ ObjC++ Var(warn_reorder) Warn when the compiler reorders code Wreturn-type -C ObjC C++ ObjC++ +C ObjC C++ ObjC++ Var(warn_return_type) Warn whenever a function's return type defaults to \"int\" (C), or about inconsistent return types (C++) Wselector diff --git a/gcc/flags.h b/gcc/flags.h index 695d6228f65..c28e16bd91e 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -101,11 +101,6 @@ extern bool extra_warnings; extern void set_Wunused (int setting); -/* Nonzero means warn about function definitions that default the return type - or that use a null return and have a return-type other than void. */ - -extern int warn_return_type; - /* Nonzero means warn about any objects definitions whose size is larger than N bytes. Also want about function definitions whose returned values are larger than N bytes. The value N is in `larger_than_size'. */ diff --git a/gcc/gcse.c b/gcc/gcse.c index 3cd1268df02..39b18bf1469 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -6529,9 +6529,9 @@ is_too_expensive (const char *pass) graceful degradation. */ if (n_edges > 20000 + n_basic_blocks * 4) { - if (warn_disabled_optimization) - warning (0, "%s: %d basic blocks and %d edges/basic block", - pass, n_basic_blocks, n_edges / n_basic_blocks); + warning (OPT_Wdisabled_optimization, + "%s: %d basic blocks and %d edges/basic block", + pass, n_basic_blocks, n_edges / n_basic_blocks); return true; } @@ -6542,9 +6542,9 @@ is_too_expensive (const char *pass) * SBITMAP_SET_SIZE (max_reg_num ()) * sizeof (SBITMAP_ELT_TYPE)) > MAX_GCSE_MEMORY) { - if (warn_disabled_optimization) - warning (0, "%s: %d basic blocks and %d registers", - pass, n_basic_blocks, max_reg_num ()); + warning (OPT_Wdisabled_optimization, + "%s: %d basic blocks and %d registers", + pass, n_basic_blocks, max_reg_num ()); return true; } diff --git a/gcc/opts.c b/gcc/opts.c index 896728c3727..5004cbf3775 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -668,7 +668,8 @@ decode_options (unsigned int argc, const char **argv) this to `2' if -Wall is used, so we can avoid giving out lots of errors for people who don't realize what -Wall does. */ if (warn_uninitialized == 1) - warning (0, "-Wuninitialized is not supported without -O"); + warning (OPT_Wuninitialized, + "-Wuninitialized is not supported without -O"); } if (flag_really_no_inline == 2) diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index cffb81c7f62..65d98f8f3ad 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -869,8 +869,7 @@ place_field (record_layout_info rli, tree field) /* No, we need to skip space before this field. Bump the cumulative size to multiple of field alignment. */ - if (warn_padded) - warning (0, "%Jpadding struct to align %qD", field, field); + warning (OPT_Wpadded, "%Jpadding struct to align %qD", field, field); /* If the alignment is still within offset_align, just align the bit position. */ diff --git a/gcc/toplev.c b/gcc/toplev.c index 9f1bb79e8f3..91cef050607 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -403,11 +403,6 @@ static const struct target_options[] = TARGET_OPTIONS; #endif -/* Nonzero means warn about function definitions that default the return type - or that use a null return and have a return-type other than void. */ - -int warn_return_type; - /* Output files for assembler code (real compiler output) and debugging dumps. */ diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 0869edcadaa..22215a39127 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2110,11 +2110,11 @@ remove_bb (basic_block bb) loop above, so the last statement we process is the first statement in the block. */ #ifdef USE_MAPPED_LOCATION - if (warn_notreached && loc > BUILTINS_LOCATION) - warning (0, "%Hwill never be executed", &loc); + if (loc > BUILTINS_LOCATION) + warning (OPT_Wunreachable_code, "%Hwill never be executed", &loc); #else - if (warn_notreached && loc) - warning (0, "%Hwill never be executed", loc); + if (loc) + warning (OPT_Wunreachable_code, "%Hwill never be executed", loc); #endif remove_phi_nodes_and_edges_for_unreachable_block (bb); |