]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r273660
authorMartin Liska <mliska@suse.cz>
Mon, 22 Jul 2019 09:38:26 +0000 (11:38 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 22 Jul 2019 09:38:26 +0000 (09:38 +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: r273666

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

index 9f12f4238153fe15901479b49bd7ac69cf6d72eb..7661fff3153b54cfaa0efb43d7e1a003988e3bd1 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-16  Wilco Dijkstra  <wdijkstr@arm.com>
 
        Backport from mainline
index 3c2553368acea71aeb4f01ee8ed46fa30c3231aa..9b0d76d1148581cc83c9e1f49b6fc8aac2920d47 100644 (file)
@@ -438,7 +438,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))
@@ -641,6 +642,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 bfa2afb1987aa6c50355128711c4622b290cf258..b45d18996a3895e918df837b39fe3b272058be81 100644 (file)
@@ -100,10 +100,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 296f93cb95b139f34a2cb4e20ad50f2f809a7db0..e0c5f0a3938825c9de4823358c55130f9216ca9a 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-16  Wilco Dijkstra  <wdijkstr@arm.com>
 
        Backport from mainline