Commit 44c21c7f by DJ Delorie Committed by DJ Delorie

c-common.c (unsigned_conversion_warning): Move warning control from if() to warning(OPT_*).

* 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.

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