From: simonb Date: Wed, 7 Apr 2010 17:18:10 +0000 (+0000) Subject: * diagnostic.h (diagnostic_override_option_index): New macro to X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;ds=sidebyside;h=3905881566fba2e9e296f1f48b29559d36f5b7c0;p=pf3gnuchains%2Fgcc-fork.git * diagnostic.h (diagnostic_override_option_index): New macro to set a diagnostic's option_index. * c-tree.h (c_cpp_error): Add warning reason argument. * opts.c (_warning_as_error_callback): New. (register_warning_as_error_callback): Store callback for warnings enabled via enable_warning_as_error. (enable_warning_as_error): Call callback, minor code tidy. * opts.h (register_warning_as_error_callback): Declare. * c-opts.c (warning_as_error_callback): New, set cpp_opts flag in response to -Werror=. (c_common_init_options): Register warning_as_error_callback in opts.c. * common.opt: Add -Wno-cpp option. * c-common.c (struct reason_option_codes_t): Map cpp warning reason codes to gcc option indexes. * (c_option_controlling_cpp_error): New function, lookup the gcc option index for a cpp warning reason code. * (c_cpp_error): Add warning reason argument, call c_option_controlling_cpp_error for diagnostic_override_option_index. * doc/invoke.texi: Document -Wno-cpp. * cpp.c (cb_cpp_error): Add warning reason argument, set a value for diagnostic_override_option_index if CPP_W_WARNING_DIRECTIVE. * directives.c (do_diagnostic): Add warning reason argument, call appropriate error reporting function for code. (directive_diagnostics): Call specific warning functions with warning reason where appropriate. (do_error, do_warning, do_pragma_dependency): Add warning reason argument to do_diagnostic calls. * macro.c (_cpp_warn_if_unused_macro, enter_macro_context, _cpp_create_definition): Call specific warning functions with warning reason where appropriate. * Makefile.in: Add new diagnostic functions to gettext translations. * include/cpplib.h (struct cpp_callbacks): Add warning reason code to error callback. (CPP_DL_WARNING, CPP_DL_WARNING_SYSHDR, CPP_DL_PEDWARN, CPP_DL_ERROR, CPP_DL_ICE, CPP_DL_NOTE, CPP_DL_FATAL): Replace macros with enums. (CPP_W_NONE, CPP_W_DEPRECATED, CPP_W_COMMENTS, CPP_W_MISSING_INCLUDE_DIRS, CPP_W_TRIGRAPHS, CPP_W_MULTICHAR, CPP_W_TRADITIONAL, CPP_W_LONG_LONG, CPP_W_ENDIF_LABELS, CPP_W_NUM_SIGN_CHANGE, CPP_W_VARIADIC_MACROS, CPP_W_BUILTIN_MACRO_REDEFINED, CPP_W_DOLLARS, CPP_W_UNDEF, CPP_W_UNUSED_MACROS, CPP_W_CXX_OPERATOR_NAMES, CPP_W_NORMALIZE, CPP_W_INVALID_PCH, CPP_W_WARNING_DIRECTIVE): New enums for cpp warning reason codes. (cpp_warning, cpp_pedwarning, cpp_warning_syshdr, cpp_warning_with_line, cpp_pedwarning_with_line, cpp_warning_with_line_syshdr): New specific error reporting functions. * pch.c (cpp_valid_state): Call specific warning functions with warning reason where appropriate. * errors.c (cpp_diagnostic, cpp_diagnostic_with_line): New central diagnostic handlers. (cpp_warning, cpp_pedwarning, cpp_warning_syshdr, cpp_warning_with_line, cpp_pedwarning_with_line, cpp_warning_with_line_syshdr): New specific error reporting functions. * expr.c (cpp_classify_number, eval_token, num_unary_op): Call specific warning functions with warning reason where appropriate. * lex.c (_cpp_process_line_notes, _cpp_skip_block_comment, warn_about_normalization, lex_identifier_intern, lex_identifier, _cpp_lex_direct): Ditto. * charset.c (_cpp_valid_ucn, convert_hex, convert_escape, narrow_str_to_charconst): Ditto. * gcc.dg/cpp/warn-undef-2.c: New. * gcc.dg/cpp/warn-traditional-2.c: New. * gcc.dg/cpp/warn-comments-2.c: New. * gcc.dg/cpp/warning-directive-1.c: New. * gcc.dg/cpp/warn-long-long.c: New. * gcc.dg/cpp/warn-traditional.c: New. * gcc.dg/cpp/warn-variadic-2.c: New. * gcc.dg/cpp/warn-undef.c: New. * gcc.dg/cpp/warn-normalized-1.c: New. * gcc.dg/cpp/warning-directive-2.c: New. * gcc.dg/cpp/warn-long-long-2.c: New. * gcc.dg/cpp/warn-variadic.c: New. * gcc.dg/cpp/warn-normalized-2.c: New. * gcc.dg/cpp/warning-directive-3.c: New. * gcc.dg/cpp/warn-deprecated-2.c: New. * gcc.dg/cpp/warn-trigraphs-1.c: New. * gcc.dg/cpp/warn-multichar-2.c: New. * gcc.dg/cpp/warn-normalized-3.c: New. * gcc.dg/cpp/warning-directive-4.c: New. * gcc.dg/cpp/warn-unused-macros.c: New. * gcc.dg/cpp/warn-trigraphs-2.c: New. * gcc.dg/cpp/warn-cxx-compat-2.c: New. * gcc.dg/cpp/warn-cxx-compat.c: New. * gcc.dg/cpp/warn-redefined.c: New. * gcc.dg/cpp/warn-trigraphs-3.c: New. * gcc.dg/cpp/warn-unused-macros-2.c: New. * gcc.dg/cpp/warn-deprecated.c: New. * gcc.dg/cpp/warn-trigraphs-4.c: New. * gcc.dg/cpp/warn-redefined-2.c: New. * gcc.dg/cpp/warn-comments.c: New. * gcc.dg/cpp/warn-multichar.c: New. * g++.dg/cpp/warning-directive-1.C: New. * g++.dg/cpp/warning-directive-2.C: New. * g++.dg/cpp/warning-directive-3.C: New. * g++.dg/cpp/warning-directive-4.C: New. * gfortran.dg/warning-directive-1.F90: New. * gfortran.dg/warning-directive-3.F90: New. * gfortran.dg/warning-directive-2.F90: New. * gfortran.dg/warning-directive-4.F90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158079 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 693d69de50a..2a6c5938422 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2010-04-07 Simon Baldwin + + * diagnostic.h (diagnostic_override_option_index): New macro to + set a diagnostic's option_index. + * c-tree.h (c_cpp_error): Add warning reason argument. + * opts.c (_warning_as_error_callback): New. + (register_warning_as_error_callback): Store callback for + warnings enabled via enable_warning_as_error. + (enable_warning_as_error): Call callback, minor code tidy. + * opts.h (register_warning_as_error_callback): Declare. + * c-opts.c (warning_as_error_callback): New, set cpp_opts flag in + response to -Werror=. + (c_common_init_options): Register warning_as_error_callback in opts.c. + * common.opt: Add -Wno-cpp option. + * c-common.c (struct reason_option_codes_t): Map cpp warning + reason codes to gcc option indexes. + * (c_option_controlling_cpp_error): New function, lookup the gcc + option index for a cpp warning reason code. + * (c_cpp_error): Add warning reason argument, call + c_option_controlling_cpp_error for diagnostic_override_option_index. + * doc/invoke.texi: Document -Wno-cpp. + 2010-04-07 Richard Guenther * ipa-reference.c (mark_load): Use get_base_address. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 76c424024e0..d356daaf021 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -232,7 +232,7 @@ Objective-C and Objective-C++ Dialects}. -Wno-attributes -Wno-builtin-macro-redefined @gol -Wc++-compat -Wc++0x-compat -Wcast-align -Wcast-qual @gol -Wchar-subscripts -Wclobbered -Wcomment @gol --Wconversion -Wcoverage-mismatch -Wno-deprecated @gol +-Wconversion -Wcoverage-mismatch -Wcpp -Wno-deprecated @gol -Wno-deprecated-declarations -Wdisabled-optimization @gol -Wno-div-by-zero -Wempty-body -Wenum-compare -Wno-endif-labels @gol -Werror -Werror=* @gol @@ -2973,6 +2973,11 @@ Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*} comment, or whenever a Backslash-Newline appears in a @samp{//} comment. This warning is enabled by @option{-Wall}. +@item -Wno-cpp \ +@r{(C, Objective-C, C++, Objective-C++ and Fortran only)} + +Suppress warning messages emitted by @code{#warning} directives. + @item -Wformat @opindex Wformat @opindex Wno-format diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2b1aa30b407..6502b89757d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2010-04-07 Simon Baldwin + + * cpp.c (cb_cpp_error): Add warning reason argument, set a value + for diagnostic_override_option_index if CPP_W_WARNING_DIRECTIVE. + 2010-04-07 Richard Guenther * options.c (gfc_init_options): Do not set. diff --git a/gcc/opts.c b/gcc/opts.c index 329f732f7d2..19d56348e2e 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -372,11 +372,13 @@ const char **in_fnames; unsigned num_in_fnames; static int common_handle_option (size_t scode, const char *arg, int value, - unsigned int lang_mask, int kind); + unsigned int lang_mask); static void handle_param (const char *); +static unsigned int handle_option (const char **argv, unsigned int lang_mask); static char *write_langs (unsigned int lang_mask); static void complain_wrong_lang (const char *, const struct cl_option *, unsigned int lang_mask); +static void handle_options (unsigned int, const char **, unsigned int); static void set_debug_level (enum debug_info_type type, int extended, const char *arg); @@ -483,57 +485,10 @@ void print_ignored_options (void) input_location = saved_loc; } - -/* Handle option OPT_INDEX, and argument ARG, for the language - indicated by LANG_MASK. VALUE is true, unless no- form of an -f or - -W option was given. KIND is the diagnostic_t if this is a - diagnostics option, DK_UNSPECIFIED otherwise. Returns false if the - switch was invalid. */ -bool -handle_option (int opt_index, int value, const char *arg, - unsigned int lang_mask, int kind) -{ - const struct cl_option *option = &cl_options[opt_index]; - - if (option->flag_var) - set_option (opt_index, value, arg, kind); - - if (option->flags & lang_mask) - { - if (lang_hooks.handle_option (opt_index, arg, value, kind) == 0) - return false; -#ifdef ENABLE_LTO - else - lto_register_user_option (opt_index, arg, value, lang_mask); - #endif - } - - if (option->flags & CL_COMMON) - { - if (common_handle_option (opt_index, arg, value, lang_mask, kind) == 0) - return false; -#ifdef ENABLE_LTO - else - lto_register_user_option (opt_index, arg, value, CL_COMMON); -#endif - } - - if (option->flags & CL_TARGET) - { - if (!targetm.handle_option (opt_index, arg, value)) - return false; -#ifdef ENABLE_LTO - else - lto_register_user_option (opt_index, arg, value, CL_TARGET); -#endif - } - return true; -} - /* Handle the switch beginning at ARGV for the language indicated by LANG_MASK. Returns the number of switches consumed. */ static unsigned int -read_cmdline_option (const char **argv, unsigned int lang_mask) +handle_option (const char **argv, unsigned int lang_mask) { size_t opt_index; const char *opt, *arg = 0; @@ -654,8 +609,32 @@ read_cmdline_option (const char **argv, unsigned int lang_mask) } } - if (!handle_option (opt_index, value, arg, lang_mask, DK_UNSPECIFIED)) - result = 0; + if (option->flag_var) + set_option (option, value, arg); + + if (option->flags & lang_mask) + { + if (lang_hooks.handle_option (opt_index, arg, value) == 0) + result = 0; + else + lto_register_user_option (opt_index, arg, value, lang_mask); + } + + if (result && (option->flags & CL_COMMON)) + { + if (common_handle_option (opt_index, arg, value, lang_mask) == 0) + result = 0; + else + lto_register_user_option (opt_index, arg, value, CL_COMMON); + } + + if (result && (option->flags & CL_TARGET)) + { + if (!targetm.handle_option (opt_index, arg, value)) + result = 0; + else + lto_register_user_option (opt_index, arg, value, CL_TARGET); + } done: if (dup) @@ -756,7 +735,7 @@ flag_instrument_functions_exclude_p (tree fndecl) contains has a single bit set representing the current language. */ static void -read_cmdline_options (unsigned int argc, const char **argv, unsigned int lang_mask) +handle_options (unsigned int argc, const char **argv, unsigned int lang_mask) { unsigned int n, i; @@ -778,7 +757,7 @@ read_cmdline_options (unsigned int argc, const char **argv, unsigned int lang_ma continue; } - n = read_cmdline_option (argv + i, lang_mask); + n = handle_option (argv + i, lang_mask); if (!n) { @@ -879,7 +858,6 @@ decode_options (unsigned int argc, const char **argv) flag_if_conversion2 = opt1; flag_ipa_pure_const = opt1; flag_ipa_reference = opt1; - flag_ipa_profile = opt1; flag_merge_constants = opt1; flag_split_wide_types = opt1; flag_tree_ccp = opt1; @@ -967,9 +945,6 @@ decode_options (unsigned int argc, const char **argv) else set_param_value ("min-crossjump-insns", initial_min_crossjump_insns); - /* Enable -Werror=coverage-mismatch by default */ - enable_warning_as_error("coverage-mismatch", 1, lang_mask); - if (first_time_p) { /* Initialize whether `char' is signed. */ @@ -986,17 +961,15 @@ decode_options (unsigned int argc, const char **argv) flag_unwind_tables = targetm.unwind_tables_default; } -#ifdef ENABLE_LTO /* Clear any options currently held for LTO. */ lto_clear_user_options (); -#endif #ifdef OPTIMIZATION_OPTIONS /* Allow default optimizations to be specified on a per-machine basis. */ OPTIMIZATION_OPTIONS (optimize, optimize_size); #endif - read_cmdline_options (argc, argv, lang_mask); + handle_options (argc, argv, lang_mask); if (dump_base_name && ! IS_ABSOLUTE_PATH (dump_base_name)) { @@ -1147,12 +1120,6 @@ decode_options (unsigned int argc, const char **argv) if (!PARAM_SET_P (PARAM_STACK_FRAME_GROWTH)) PARAM_VALUE (PARAM_STACK_FRAME_GROWTH) = 40; } - if (flag_wpa || flag_ltrans) - { - /* These passes are not WHOPR compatible yet. */ - flag_ipa_pta = 0; - flag_ipa_struct_reorg = 0; - } if (flag_lto || flag_whopr) { @@ -1487,7 +1454,7 @@ print_specific_help (unsigned int include_flags, static int common_handle_option (size_t scode, const char *arg, int value, - unsigned int lang_mask, int kind ATTRIBUTE_UNUSED) + unsigned int lang_mask) { static bool verbose = false; enum opt_code code = (enum opt_code) scode; @@ -1790,7 +1757,7 @@ common_handle_option (size_t scode, const char *arg, int value, break; case OPT_fdiagnostics_show_option: - global_dc->show_option_requested = value; + global_dc->show_option_requested = true; break; case OPT_fdump_: @@ -2149,10 +2116,6 @@ common_handle_option (size_t scode, const char *arg, int value, flag_pedantic_errors = pedantic = 1; break; - case OPT_fwhopr: - flag_whopr = value; - break; - case OPT_fsee: case OPT_fcse_skip_blocks: case OPT_floop_optimize: @@ -2400,10 +2363,8 @@ get_option_state (int option, struct cl_option_state *state) /* Set *OPTION according to VALUE and ARG. */ void -set_option (int opt_index, int value, const char *arg, int kind) +set_option (const struct cl_option *option, int value, const char *arg) { - const struct cl_option *option = &cl_options[opt_index]; - if (!option->flag_var) return; @@ -2433,9 +2394,6 @@ set_option (int opt_index, int value, const char *arg, int kind) *(const char **) option->flag_var = arg; break; } - - if ((diagnostic_t)kind != DK_UNSPECIFIED) - diagnostic_classify_diagnostic (global_dc, opt_index, (diagnostic_t)kind); } @@ -2479,8 +2437,8 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask) const struct cl_option * const option = cl_options + option_index; /* -Werror=foo implies -Wfoo. */ - if (option->var_type == CLVC_BOOLEAN) - handle_option (option_index, value, arg, lang_mask, (int)kind); + if (option->var_type == CLVC_BOOLEAN && option->flag_var) + *(int *) option->flag_var = 1; if (warning_as_error_callback) warning_as_error_callback (option_index); diff --git a/gcc/opts.h b/gcc/opts.h index af3c6e2abe6..54f57d114a3 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -103,9 +103,8 @@ extern void prune_options (int *argcp, char ***argvp); extern void decode_options (unsigned int argc, const char **argv); extern int option_enabled (int opt_idx); extern bool get_option_state (int, struct cl_option_state *); -extern void set_option (int opt_index, int value, const char *arg, int); -bool handle_option (int opt_index, int value, const char *arg, - unsigned int lang_mask, int kind); +extern void set_option (const struct cl_option *, int, const char *); + extern void register_warning_as_error_callback (void (*callback) (int)); extern void enable_warning_as_error (const char *arg, int value, unsigned int lang_mask); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a074ef23d7c..81684784874 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,47 @@ -2010-04-07 Iain Sandoe +2010-04-07 Simon Baldwin + + * gcc.dg/cpp/warn-undef-2.c: New. + * gcc.dg/cpp/warn-traditional-2.c: New. + * gcc.dg/cpp/warn-comments-2.c: New. + * gcc.dg/cpp/warning-directive-1.c: New. + * gcc.dg/cpp/warn-long-long.c: New. + * gcc.dg/cpp/warn-traditional.c: New. + * gcc.dg/cpp/warn-variadic-2.c: New. + * gcc.dg/cpp/warn-undef.c: New. + * gcc.dg/cpp/warn-normalized-1.c: New. + * gcc.dg/cpp/warning-directive-2.c: New. + * gcc.dg/cpp/warn-long-long-2.c: New. + * gcc.dg/cpp/warn-variadic.c: New. + * gcc.dg/cpp/warn-normalized-2.c: New. + * gcc.dg/cpp/warning-directive-3.c: New. + * gcc.dg/cpp/warn-deprecated-2.c: New. + * gcc.dg/cpp/warn-trigraphs-1.c: New. + * gcc.dg/cpp/warn-multichar-2.c: New. + * gcc.dg/cpp/warn-normalized-3.c: New. + * gcc.dg/cpp/warning-directive-4.c: New. + * gcc.dg/cpp/warn-unused-macros.c: New. + * gcc.dg/cpp/warn-trigraphs-2.c: New. + * gcc.dg/cpp/warn-cxx-compat-2.c: New. + * gcc.dg/cpp/warn-cxx-compat.c: New. + * gcc.dg/cpp/warn-redefined.c: New. + * gcc.dg/cpp/warn-trigraphs-3.c: New. + * gcc.dg/cpp/warn-unused-macros-2.c: New. + * gcc.dg/cpp/warn-deprecated.c: New. + * gcc.dg/cpp/warn-trigraphs-4.c: New. + * gcc.dg/cpp/warn-redefined-2.c: New. + * gcc.dg/cpp/warn-comments.c: New. + * gcc.dg/cpp/warn-multichar.c: New. + * g++.dg/cpp/warning-directive-1.C: New. + * g++.dg/cpp/warning-directive-2.C: New. + * g++.dg/cpp/warning-directive-3.C: New. + * g++.dg/cpp/warning-directive-4.C: New. + * gfortran.dg/warning-directive-1.F90: New. + * gfortran.dg/warning-directive-3.F90: New. + * gfortran.dg/warning-directive-2.F90: New. + * gfortran.dg/warning-directive-4.F90: New. - PR objc++/23716 +2010-04-07 Iain Sandoe +PR objc++/23716 * obj-c++.dg/comp-types-10.mm: Remove XFAIL. 2010-04-07 Jason Merrill diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-1.C b/gcc/testsuite/g++.dg/cpp/warning-directive-1.C new file mode 100644 index 00000000000..1ce18c6e2c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/warning-directive-1.C @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-fdiagnostics-show-option" } + +#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-2.C b/gcc/testsuite/g++.dg/cpp/warning-directive-2.C new file mode 100644 index 00000000000..abd6427cd8a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/warning-directive-2.C @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-fdiagnostics-show-option -Werror=cpp" } + +#warning "Printed" // { dg-error "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-3.C b/gcc/testsuite/g++.dg/cpp/warning-directive-3.C new file mode 100644 index 00000000000..8ed66c66f1d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/warning-directive-3.C @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-fdiagnostics-show-option -Werror -Wno-error=cpp" } + +#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/g++.dg/cpp/warning-directive-4.C b/gcc/testsuite/g++.dg/cpp/warning-directive-4.C new file mode 100644 index 00000000000..a5db1b4d5cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/warning-directive-4.C @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-fdiagnostics-show-option -Wno-cpp" } + +#warning "Not printed" // { dg-bogus "." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c b/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c index 17cc9f1ce15..5a17f2bdcf2 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-comments-2.c @@ -1,7 +1,7 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=comments" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -/* /* */ // { dg-error "\"\.\*\" within comment .-Werror=comments." } + +/* /* */ // { dg-error "\"\.\*\" within comment .-Wcomments." } // \ - // { dg-error "multi-line comment .-Werror=comments." "multi-line" { target *-*-* } 6 } + // { dg-error "multi-line comment .-Wcomments." "multi-line" { target *-*-* } 6 } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c index 69c4cfa0c3e..6bf7d555e14 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-cxx-compat-2.c @@ -1,4 +1,4 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=c++-compat" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#define not ! // { dg-error "identifier \"not\" is a special operator name in C\\+\\+ .-Werror=c\\+\\+-compat." } + +#define not ! // { dg-error "identifier \"not\" is a special operator name in C\\+\\+ .-Wc\\+\\+-compat." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c b/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c index 8bd608ab794..b9cfffb9630 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-deprecated-2.c @@ -1,7 +1,7 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=deprecated" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#assert x(x) // { dg-error "#assert is a deprecated GCC extension .-Werror=deprecated." } -#if #x(x) // { dg-error "assertions are a deprecated extension .-Werror=deprecated." } +#assert x(x) // { dg-error "#assert is a deprecated GCC extension .-Wdeprecated." } + +#if #x(x) // { dg-error "assertions are a deprecated extension .-Wdeprecated." } #endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c b/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c index 7b074a37c90..11eb5fb2666 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-long-long-2.c @@ -1,6 +1,6 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Wtraditional -Werror=long-long" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#if 0LL // { dg-error "traditional C rejects the \"LL\" suffix .-Werror=long-long." } - // { dg-error "use of C99 long long integer constant .-Werror=long-long." "use long long" { target *-*-* } 4 } + +#if 0LL // { dg-error "traditional C rejects the \"LL\" suffix .-Wlong-long." } + // { dg-error "use of C99 long long integer constant .-Wlong-long." "use long long" { target *-*-* } 4 } #endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c b/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c index f9fd4f6dfa0..31d33bb9bb8 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-multichar-2.c @@ -1,5 +1,5 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=multichar" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#if 'abc' // { dg-error "multi-character character constant .-Werror=multichar." } + +#if 'abc' // { dg-error "multi-character character constant .-Wmultichar." } #endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c index 24eaea035e7..380c670b8af 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-3.c @@ -1,5 +1,5 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -fextended-identifiers -Werror=normalized=" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ + // { dg-prune-output ".*-Werror=normalized=: Set -Wnormalized=nfc.*" } -\u0F43 // { dg-error "`.U00000f43' is not in NFC .-Werror=normalized=." } +\u0F43 // { dg-error "`.U00000f43' is not in NFC .-Wnormalized=." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c b/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c index e6b209c1e70..83cc3df7610 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-redefined-2.c @@ -1,12 +1,12 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=builtin-macro-redefined" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ + #ifndef __TIME__ #error "__TIME__ builtin is not defined" // { dg-bogus "__TIME__ builtin is not defined" "no-time" { target *-*-* } 5 } #endif -#define __TIME__ "X" // { dg-error "\"__TIME__\" redefined .-Werror=builtin-macro-redefined." } +#define __TIME__ "X" // { dg-error "\"__TIME__\" redefined .-Wbuiltin-macro-redefined." } #define __TIME__ "Y" // { dg-bogus "-Wbuiltin-macro-redefined" } // { dg-warning "\"__TIME__\" redefined" "not-builtin-1" { target *-*-* } 11 } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c b/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c index 05477afefa9..cb5f690ccf7 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-traditional-2.c @@ -1,23 +1,23 @@ // { dg-do compile } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=traditional -Wno-deprecated -Wno-long-long" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#assert x(x) // { dg-error "suggest hiding #assert from traditional C with an indented # .-Werror=traditional." } - #define X X // { dg-error "traditional C ignores #define with the # indented .-Werror=traditional." } +#assert x(x) // { dg-error "suggest hiding #assert from traditional C with an indented # .-Wtraditional." } + + #define X X // { dg-error "traditional C ignores #define with the # indented .-Wtraditional." } #if 0 -#elif 1 // { dg-error "suggest not using #elif in traditional C .-Werror=traditional." } +#elif 1 // { dg-error "suggest not using #elif in traditional C .-Wtraditional." } #endif #define f(X) X -int f; // { dg-error "function-like macro \"f\" must be used with arguments in traditional C .-Werror=traditional." } +int f; // { dg-error "function-like macro \"f\" must be used with arguments in traditional C .-Wtraditional." } -#if 0U // { dg-error "traditional C rejects the \"U\" suffix .-Werror=traditional." } +#if 0U // { dg-error "traditional C rejects the \"U\" suffix .-Wtraditional." } #endif -#if +1 // { dg-error " traditional C rejects the unary plus operator .-Werror=traditional." } +#if +1 // { dg-error " traditional C rejects the unary plus operator .-Wtraditional." } #endif -char *x = "\x0"; // { dg-error "the meaning of '.x' is different in traditional C .-Werror=traditional." } -char *y = "\a"; // { dg-error "the meaning of '.a' is different in traditional C .-Werror=traditional." } -char *z = "\u0F43"; // { dg-error "the meaning of '.u' is different in traditional C .-Werror=traditional." } +char *x = "\x0"; // { dg-error "the meaning of '.x' is different in traditional C .-Wtraditional." } +char *y = "\a"; // { dg-error "the meaning of '.a' is different in traditional C .-Wtraditional." } +char *z = "\u0F43"; // { dg-error "the meaning of '.u' is different in traditional C .-Wtraditional." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c index e7537c8684d..a993e2a190c 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-3.c @@ -1,4 +1,4 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -trigraphs -Werror=trigraphs" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -??= // { dg-error "trigraph \\?\\?= converted to # .-Werror=trigraphs." } + +??= // { dg-error "trigraph \\?\\?= converted to # .-Wtrigraphs." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c index d8333d4c3b5..240ae0f2175 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-trigraphs-4.c @@ -1,4 +1,4 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=trigraphs" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -??= // { dg-error "trigraph \\?\\?= ignored, use -trigraphs to enable .-Werror=trigraphs." } + +??= // { dg-error "trigraph \\?\\?= ignored, use -trigraphs to enable .-Wtrigraphs." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c index 15fdde95c10..4eb80e0e945 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-undef-2.c @@ -1,5 +1,5 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=undef" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#if x // { dg-error "\"x\" is not defined .-Werror=undef." } + +#if x // { dg-error "\"x\" is not defined .-Wundef." } #endif diff --git a/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c index d7fe145c8cc..58eeebfcdd9 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-unused-macros-2.c @@ -1,4 +1,4 @@ // { dg-do preprocess } // { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=unused-macros" } -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#define X X // { dg-error "macro \"X\" is not used .-Werror=unused-macros." } + +#define X X // { dg-error "macro \"X\" is not used .-Wunused-macros." } diff --git a/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c b/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c index 1a266cd245f..f43d96ab81b 100644 --- a/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c +++ b/gcc/testsuite/gcc.dg/cpp/warn-variadic-2.c @@ -1,6 +1,6 @@ /* { dg-do preprocess } */ /* { dg-options "-ansi -fdiagnostics-show-option -pedantic -Werror=variadic-macros" } */ -/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */ -#define F(...) X /* { dg-error "anonymous variadic macros were introduced in C99 .-Werror=variadic-macros." } */ -#define G(X...) X /* { dg-error "ISO C does not permit named variadic macros .-Werror=variadic-macros." } */ +#define F(...) X /* { dg-error "anonymous variadic macros were introduced in C99 .-Wvariadic-macros." } */ + +#define G(X...) X /* { dg-error "ISO C does not permit named variadic macros .-Wvariadic-macros." } */ diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c new file mode 100644 index 00000000000..cb4bd326cc2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-1.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option" } + +#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c new file mode 100644 index 00000000000..0889803cd11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-2.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=cpp" } + +#warning "Printed" // { dg-error "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c new file mode 100644 index 00000000000..48c97f3ac5b --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-3.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror -Wno-error=cpp" } + +#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." } diff --git a/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c b/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c new file mode 100644 index 00000000000..2eb101765da --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/warning-directive-4.c @@ -0,0 +1,4 @@ +// { dg-do preprocess } +// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wno-cpp" } + +#warning "Not printed" // { dg-bogus "." } diff --git a/gcc/testsuite/gfortran.dg/warning-directive-2.F90 b/gcc/testsuite/gfortran.dg/warning-directive-2.F90 index fa9460a787f..75b78bf6dd9 100644 --- a/gcc/testsuite/gfortran.dg/warning-directive-2.F90 +++ b/gcc/testsuite/gfortran.dg/warning-directive-2.F90 @@ -1,5 +1,5 @@ ! { dg-do preprocess } ! { dg-options "-std=f95 -fdiagnostics-show-option -Werror=cpp" } -! { dg-warning "some warnings being treated as errors" "" {target "*-*-*"} 0 } + #warning "Printed" -! { dg-error "\"Printed\" .-Werror=cpp." "" { target *-*-* } 4 } +! { dg-error "\"Printed\" .-Wcpp." "" { target *-*-* } 4 } diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index b55d25576e7..7762099dd12 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,45 @@ +2010-04-07 Simon Baldwin + + * directives.c (do_diagnostic): Add warning reason argument, + call appropriate error reporting function for code. + (directive_diagnostics): Call specific warning functions with + warning reason where appropriate. + (do_error, do_warning, do_pragma_dependency): Add warning reason + argument to do_diagnostic calls. + * macro.c (_cpp_warn_if_unused_macro, enter_macro_context, + _cpp_create_definition): Call specific warning functions with + warning reason where appropriate. + * Makefile.in: Add new diagnostic functions to gettext translations. + * include/cpplib.h (struct cpp_callbacks): Add warning reason code + to error callback. + (CPP_DL_WARNING, CPP_DL_WARNING_SYSHDR, CPP_DL_PEDWARN, CPP_DL_ERROR, + CPP_DL_ICE, CPP_DL_NOTE, CPP_DL_FATAL): Replace macros with enums. + (CPP_W_NONE, CPP_W_DEPRECATED, CPP_W_COMMENTS, + CPP_W_MISSING_INCLUDE_DIRS, CPP_W_TRIGRAPHS, CPP_W_MULTICHAR, + CPP_W_TRADITIONAL, CPP_W_LONG_LONG, CPP_W_ENDIF_LABELS, + CPP_W_NUM_SIGN_CHANGE, CPP_W_VARIADIC_MACROS, + CPP_W_BUILTIN_MACRO_REDEFINED, CPP_W_DOLLARS, CPP_W_UNDEF, + CPP_W_UNUSED_MACROS, CPP_W_CXX_OPERATOR_NAMES, CPP_W_NORMALIZE, + CPP_W_INVALID_PCH, CPP_W_WARNING_DIRECTIVE): New enums for cpp + warning reason codes. + (cpp_warning, cpp_pedwarning, cpp_warning_syshdr, + cpp_warning_with_line, cpp_pedwarning_with_line, + cpp_warning_with_line_syshdr): New specific error reporting functions. + * pch.c (cpp_valid_state): Call specific warning functions with + warning reason where appropriate. + * errors.c (cpp_diagnostic, cpp_diagnostic_with_line): New central + diagnostic handlers. + (cpp_warning, cpp_pedwarning, cpp_warning_syshdr, + cpp_warning_with_line, cpp_pedwarning_with_line, + cpp_warning_with_line_syshdr): New specific error reporting functions. + * expr.c (cpp_classify_number, eval_token, num_unary_op): Call + specific warning functions with warning reason where appropriate. + * lex.c (_cpp_process_line_notes, _cpp_skip_block_comment, + warn_about_normalization, lex_identifier_intern, lex_identifier, + _cpp_lex_direct): Ditto. + * charset.c (_cpp_valid_ucn, convert_hex, convert_escape, + narrow_str_to_charconst): Ditto. + 2010-04-06 Jakub Jelinek PR preprocessor/43642 diff --git a/libcpp/lex.c b/libcpp/lex.c index f2999822534..f6282729946 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -301,14 +301,16 @@ _cpp_process_line_notes (cpp_reader *pfile, int in_comment) && (!in_comment || warn_in_comment (pfile, note))) { if (CPP_OPTION (pfile, trigraphs)) - cpp_error_with_line (pfile, CPP_DL_WARNING, pfile->line_table->highest_line, col, - "trigraph ??%c converted to %c", - note->type, - (int) _cpp_trigraph_map[note->type]); + cpp_warning_with_line (pfile, CPP_W_TRIGRAPHS, + pfile->line_table->highest_line, col, + "trigraph ??%c converted to %c", + note->type, + (int) _cpp_trigraph_map[note->type]); else { - cpp_error_with_line - (pfile, CPP_DL_WARNING, pfile->line_table->highest_line, col, + cpp_warning_with_line + (pfile, CPP_W_TRIGRAPHS, + pfile->line_table->highest_line, col, "trigraph ??%c ignored, use -trigraphs to enable", note->type); } @@ -355,9 +357,10 @@ _cpp_skip_block_comment (cpp_reader *pfile) && cur[0] == '*' && cur[1] != '/') { buffer->cur = cur; - cpp_error_with_line (pfile, CPP_DL_WARNING, - pfile->line_table->highest_line, CPP_BUF_COL (buffer), - "\"/*\" within comment"); + cpp_warning_with_line (pfile, CPP_W_COMMENTS, + pfile->line_table->highest_line, + CPP_BUF_COL (buffer), + "\"/*\" within comment"); } } else if (c == '\n') @@ -460,11 +463,11 @@ warn_about_normalization (cpp_reader *pfile, sz = cpp_spell_token (pfile, token, buf, false) - buf; if (NORMALIZE_STATE_RESULT (s) == normalized_C) - cpp_error_with_line (pfile, CPP_DL_WARNING, token->src_loc, 0, - "`%.*s' is not in NFKC", (int) sz, buf); + cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0, + "`%.*s' is not in NFKC", (int) sz, buf); else - cpp_error_with_line (pfile, CPP_DL_WARNING, token->src_loc, 0, - "`%.*s' is not in NFC", (int) sz, buf); + cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0, + "`%.*s' is not in NFC", (int) sz, buf); } } @@ -545,9 +548,9 @@ lex_identifier_intern (cpp_reader *pfile, const uchar *base) /* For -Wc++-compat, warn about use of C++ named operators. */ if (result->flags & NODE_WARN_OPERATOR) - cpp_error (pfile, CPP_DL_WARNING, - "identifier \"%s\" is a special operator name in C++", - NODE_NAME (result)); + cpp_warning (pfile, CPP_W_CXX_OPERATOR_NAMES, + "identifier \"%s\" is a special operator name in C++", + NODE_NAME (result)); } return result; @@ -622,9 +625,9 @@ lex_identifier (cpp_reader *pfile, const uchar *base, bool starts_ucn, /* For -Wc++-compat, warn about use of C++ named operators. */ if (result->flags & NODE_WARN_OPERATOR) - cpp_error (pfile, CPP_DL_WARNING, - "identifier \"%s\" is a special operator name in C++", - NODE_NAME (result)); + cpp_warning (pfile, CPP_W_CXX_OPERATOR_NAMES, + "identifier \"%s\" is a special operator name in C++", + NODE_NAME (result)); } return result; @@ -1531,7 +1534,7 @@ _cpp_lex_direct (cpp_reader *pfile) } if (skip_line_comment (pfile) && CPP_OPTION (pfile, warn_comments)) - cpp_error (pfile, CPP_DL_WARNING, "multi-line comment"); + cpp_warning (pfile, CPP_W_COMMENTS, "multi-line comment"); } else if (c == '=') {