From fd419914ddab9bc8eba26df31310b76f14560502 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Mon, 8 May 2017 20:58:41 +0000 Subject: gcc 4.9 makes unknown -Wno-* vanish. Reimplement that from scratch in our ancient gcc, because it's really useful for porting newer code and dealing with compiler variations. (slightly tweaked to reset location to unknown location after the okays) okay kettenis@ jasper@ found out https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28322 after the patch, which explains a similar reasoning better, and leads to another patch for older GCC, possibly GPLv3. --- gnu/gcc/gcc/opts.c | 24 ++++++++++++++++++++++-- gnu/gcc/gcc/opts.h | 1 + gnu/gcc/gcc/toplev.c | 3 +++ 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'gnu/gcc') diff --git a/gnu/gcc/gcc/opts.c b/gnu/gcc/gcc/opts.c index b6217e8df4a..003fa82745c 100644 --- a/gnu/gcc/gcc/opts.c +++ b/gnu/gcc/gcc/opts.c @@ -195,6 +195,18 @@ complain_wrong_lang (const char *text, const struct cl_option *option, free (bad_lang); } +static const char *bad_option = NULL; + +void +late_options_error (void) +{ + if (bad_option) + { + input_location = unknown_location; + error ("unrecognized command line option \"%s\"", bad_option); + } +} + /* Handle the switch beginning at ARGV for the language indicated by LANG_MASK. Returns the number of switches consumed. */ static unsigned int @@ -226,8 +238,16 @@ handle_option (const char **argv, unsigned int lang_mask) opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET); } - if (opt_index == cl_options_count) - goto done; + if (opt_index == cl_options_count) + { + /* ignore unknown -Wno-* options */ + if (value == 0 && opt[1] == 'W') + { + bad_option = argv[0]; + result = 1; + } + goto done; + } option = &cl_options[opt_index]; diff --git a/gnu/gcc/gcc/opts.h b/gnu/gcc/gcc/opts.h index 3af501fbf99..fee202dcb4b 100644 --- a/gnu/gcc/gcc/opts.h +++ b/gnu/gcc/gcc/opts.h @@ -88,6 +88,7 @@ extern unsigned num_in_fnames; size_t find_opt (const char *input, int lang_mask); extern void prune_options (int *argcp, char ***argvp); extern void decode_options (unsigned int argc, const char **argv); +extern void late_options_error (void); extern int option_enabled (int opt_idx); extern bool get_option_state (int, struct cl_option_state *); diff --git a/gnu/gcc/gcc/toplev.c b/gnu/gcc/gcc/toplev.c index 39b92e10b23..501505fe30a 100644 --- a/gnu/gcc/gcc/toplev.c +++ b/gnu/gcc/gcc/toplev.c @@ -2045,7 +2045,10 @@ toplev_main (unsigned int argc, const char **argv) do_compile (); if (errorcount || sorrycount) + { + late_options_error (); return (FATAL_EXIT_CODE); + } return (SUCCESS_EXIT_CODE); } -- cgit v1.2.3