]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r273660
authorMartin Liska <mliska@suse.cz>
Mon, 22 Jul 2019 09:37:18 +0000 (11:37 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 22 Jul 2019 09:37:18 +0000 (09:37 +0000)
2019-07-22  Martin Liska  <mliska@suse.cz>

Backport from mainline
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>

Backport from mainline
2019-07-22  Martin Liska  <mliska@suse.cz>

PR driver/91172
* gcc.dg/pr91172.c: New test.

From-SVN: r273664

gcc/ChangeLog
gcc/opts-common.c
gcc/opts-global.c
gcc/testsuite/ChangeLog

index 258a5d0b288eb94ce35a9ba21a6dcaf45fa52034..c364b62e8e261da881caa630724033e14f0fb2f5 100644 (file)
@@ -1,3 +1,13 @@
+2019-07-22  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       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  Claudiu Zissulescu  <claziss@synopsys.com>
 
        Backport from mainline.
index 8456dcc697bbb3a0078afd00a948bfa3d558446d..d0b943bc8191f244e51c4182d499403388ad2069 100644 (file)
@@ -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)
index a5e9ef0237aac6fe191e2f4e68929ba6b8c4eeb9..4f8aac7e9d82ab3b49d23698a3215a00890fc99c 100644 (file)
@@ -103,10 +103,14 @@ complain_wrong_lang (const struct cl_decoded_option *decoded,
           text, bad_lang);
   else if (lang_mask == CL_DRIVER)
     gcc_unreachable ();
-  else
+  else if (ok_langs[0] != '\0')
     /* Eventually this should become a hard error IMO.  */
     warning (0, "command line option %qs is valid for %s but not for %s",
             text, ok_langs, bad_lang);
+  else
+    /* Happens for -Werror=warning_name.  */
+    warning (0, "%<-Werror=%> argument %qs is not valid for %s",
+            text, bad_lang);
 
   free (ok_langs);
   free (bad_lang);
index b028bfdedf967f6e2aea68165f07647fb038d5d9..c497b79a7cf912f37e37641b0ab23d3b52222332 100644 (file)
@@ -1,3 +1,11 @@
+2019-07-22  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2019-07-22  Martin Liska  <mliska@suse.cz>
+
+       PR driver/91172
+       * gcc.dg/pr91172.c: New test.
+
 2019-07-22  Claudiu Zissulescu  <claziss@synopsys.com>
 
        Backport from mainline