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
+2010-04-07 Simon Baldwin <simonb@google.com>
+
+ * 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 <rguenther@suse.de>
* ipa-reference.c (mark_load): Use get_base_address.
-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
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
+2010-04-07 Simon Baldwin <simonb@google.com>
+
+ * 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 <rguenther@suse.de>
* options.c (gfc_init_options): Do not set.
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);
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;
}
}
- 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)
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;
continue;
}
- n = read_cmdline_option (argv + i, lang_mask);
+ n = handle_option (argv + i, lang_mask);
if (!n)
{
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;
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. */
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))
{
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)
{
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;
break;
case OPT_fdiagnostics_show_option:
- global_dc->show_option_requested = value;
+ global_dc->show_option_requested = true;
break;
case OPT_fdump_:
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:
/* 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;
*(const char **) option->flag_var = arg;
break;
}
-
- if ((diagnostic_t)kind != DK_UNSPECIFIED)
- diagnostic_classify_diagnostic (global_dc, opt_index, (diagnostic_t)kind);
}
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);
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);
-2010-04-07 Iain Sandoe <iains@gcc.gnu.org>
+2010-04-07 Simon Baldwin <simonb@google.com>
+
+ * 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 <iains@gcc.gnu.org>
+PR objc++/23716
* obj-c++.dg/comp-types-10.mm: Remove XFAIL.
2010-04-07 Jason Merrill <jason@redhat.com>
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option" }
+
+#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." }
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option -Werror=cpp" }
+
+#warning "Printed" // { dg-error "\"Printed\" .-Wcpp." }
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option -Werror -Wno-error=cpp" }
+
+#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." }
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-fdiagnostics-show-option -Wno-cpp" }
+
+#warning "Not printed" // { dg-bogus "." }
// { 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 }
// { 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." }
// { 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
// { 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
// { 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
// { 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=." }
// { 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 }
// { 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." }
// { 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." }
// { 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." }
// { 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
// { 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." }
/* { 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." } */
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option" }
+
+#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." }
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=cpp" }
+
+#warning "Printed" // { dg-error "\"Printed\" .-Wcpp." }
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror -Wno-error=cpp" }
+
+#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." }
--- /dev/null
+// { dg-do preprocess }
+// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wno-cpp" }
+
+#warning "Not printed" // { dg-bogus "." }
! { 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 }
+2010-04-07 Simon Baldwin <simonb@google.com>
+
+ * 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 <jakub@redhat.com>
PR preprocessor/43642
&& (!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);
}
&& 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')
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);
}
}
/* 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;
/* 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;
}
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 == '=')
{