aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2008-02-25 23:41:43 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2008-02-25 23:41:43 +0000
commit369dcbd9d2f7d4577f689b46ee3028bc7949049c (patch)
tree3c64cf898a8a27198eb86ae7840a3237d55c24f0 /gcc/opts.c
parent23dc794c0e7bb0d82dbbe118a435d17c31af6732 (diff)
downloadgcc-369dcbd9d2f7d4577f689b46ee3028bc7949049c.zip
gcc-369dcbd9d2f7d4577f689b46ee3028bc7949049c.tar.gz
gcc-369dcbd9d2f7d4577f689b46ee3028bc7949049c.tar.bz2
re PR other/28322 (GCC new warnings and compatibility)
2008-02-26 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR 28322 * toplev.c (toplev_main): If there are warnings or error, print errors for ignored options. * opts.c (ignored_options): New static variable. (postpone_unknown_option_error): New. (print_ignored_options): New. (handle_option): Postpone errors for unknown -Wno-* options. * opts.h (print_ignored_options): Declare. testsuite/ * gcc.dg/pr28322.c: New. * gcc.dg/pr28322-2.c: New. * lib/prune.exp: Ignore "At top level" even if there is no ':' preceding it. From-SVN: r132648
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index 8b8a1a9..8bee44b 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -365,6 +365,12 @@ DEF_VEC_ALLOC_P(char_p,heap);
static VEC(char_p,heap) *flag_instrument_functions_exclude_functions;
static VEC(char_p,heap) *flag_instrument_functions_exclude_files;
+typedef const char *const_char_p; /* For DEF_VEC_P. */
+DEF_VEC_P(const_char_p);
+DEF_VEC_ALLOC_P(const_char_p,heap);
+
+static VEC(const_char_p,heap) *ignored_options;
+
/* Input file names. */
const char **in_fnames;
unsigned num_in_fnames;
@@ -443,6 +449,33 @@ complain_wrong_lang (const char *text, const struct cl_option *option,
free (bad_lang);
}
+/* Buffer the unknown option described by the string OPT. Currently,
+ we only complain about unknown -Wno-* options if they may have
+ prevented a diagnostic. Otherwise, we just ignore them. */
+
+static void postpone_unknown_option_error(const char *opt)
+{
+ VEC_safe_push (const_char_p, heap, ignored_options, opt);
+}
+
+/* Produce an error for each option previously buffered. */
+
+void print_ignored_options (void)
+{
+ location_t saved_loc = input_location;
+
+ input_location = 0;
+
+ while (!VEC_empty (const_char_p, ignored_options))
+ {
+ const char *opt;
+ opt = VEC_pop (const_char_p, ignored_options);
+ error ("unrecognized command line option \"%s\"", opt);
+ }
+
+ input_location = saved_loc;
+}
+
/* Handle the switch beginning at ARGV for the language indicated by
LANG_MASK. Returns the number of switches consumed. */
static unsigned int
@@ -472,6 +505,14 @@ handle_option (const char **argv, unsigned int lang_mask)
opt = dup;
value = 0;
opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
+ if (opt_index == cl_options_count)
+ {
+ /* We don't generate errors for unknown -Wno-* options
+ unless we issue diagnostics. */
+ postpone_unknown_option_error (argv[0]);
+ result = 1;
+ goto done;
+ }
}
if (opt_index == cl_options_count)