+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
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");
}
}
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:
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.
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;
}
|| (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;
}
/*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;
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);
}
#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. */
{
/* 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)
{
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");
}
}
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");
}
}
}
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)
/* 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. */
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:
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;
}
/* 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
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)
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)
{
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;
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
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'. */
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;
}
* 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;
}
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)
/* 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. */
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. */
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);