diff options
author | Martin Liska <mliska@suse.cz> | 2019-07-22 09:34:10 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2019-07-22 07:34:10 +0000 |
commit | 2df89b66f1b397c9eacd2078eb6a9b52c2c4853f (patch) | |
tree | 1981847c71cd677128a920c3d4614aed2433be88 /gcc/opts-common.c | |
parent | 4be6c9b9a2085b32be37df4216c37b395c7bd1a2 (diff) | |
download | gcc-2df89b66f1b397c9eacd2078eb6a9b52c2c4853f.zip gcc-2df89b66f1b397c9eacd2078eb6a9b52c2c4853f.tar.gz gcc-2df89b66f1b397c9eacd2078eb6a9b52c2c4853f.tar.bz2 |
Make a warning for -Werror=wrong-language (PR driver/91172).
2019-07-22 Martin Liska <mliska@suse.cz>
PR driver/91172
* opts-common.c (decode_cmdline_option): Decode
argument of -Werror and check it for a wrong language.
* opts-global.c (complain_wrong_lang): Remove such case.
2019-07-22 Martin Liska <mliska@suse.cz>
PR driver/91172
* gcc.dg/pr91172.c: New test.
From-SVN: r273660
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r-- | gcc/opts-common.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 660dfe6..e3f9c54 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -537,7 +537,8 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, extra_args = 0; - opt_index = find_opt (argv[0] + 1, lang_mask); + const char *opt_value = argv[0] + 1; + opt_index = find_opt (opt_value, lang_mask); i = 0; while (opt_index == OPT_SPECIAL_unknown && i < ARRAY_SIZE (option_map)) @@ -745,6 +746,23 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask, /* Check if this is a switch for a different front end. */ if (!option_ok_for_language (option, lang_mask)) errors |= CL_ERR_WRONG_LANG; + else if (strcmp (option->opt_text, "-Werror=") == 0 + && strchr (opt_value, ',') == NULL) + { + /* Verify that -Werror argument is a valid warning + for a language. */ + char *werror_arg = xstrdup (opt_value + 6); + werror_arg[0] = 'W'; + + size_t warning_index = find_opt (werror_arg, lang_mask); + if (warning_index != OPT_SPECIAL_unknown) + { + const struct cl_option *warning_option + = &cl_options[warning_index]; + if (!option_ok_for_language (warning_option, lang_mask)) + errors |= CL_ERR_WRONG_LANG; + } + } /* Convert the argument to lowercase if appropriate. */ if (arg && option->cl_tolower) |