]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/59304 (#pragma diagnostic pop after warning fails for options unspecified...
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Wed, 20 Aug 2014 12:48:16 +0000 (12:48 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Wed, 20 Aug 2014 12:48:16 +0000 (12:48 +0000)
gcc/ChangeLog:

2014-08-20  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c/59304
* opts-common.c (set_option): Call diagnostic_classify_diagnostic
before setting the option.
* diagnostic.c (diagnostic_classify_diagnostic): Record
command-line status.

gcc/testsuite/ChangeLog:

2014-08-20  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c/59304
* gcc.dg/pr59304.c: New test.

From-SVN: r214221

gcc/ChangeLog
gcc/diagnostic.c
gcc/opts-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr59304.c [new file with mode: 0644]

index 360db1140c8f9c44f7e2a32fcc64481bd4264acc..00497633a9be53d645f7049114f6df05e6a72966 100644 (file)
@@ -1,3 +1,11 @@
+2014-08-20  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c/59304
+       * opts-common.c (set_option): Call diagnostic_classify_diagnostic
+       before setting the option.
+       * diagnostic.c (diagnostic_classify_diagnostic): Record
+       command-line status.
+
 2014-08-20  Richard Biener  <rguenther@suse.de>
 
        PR lto/62190
index 2226821bc4934817f24fc51a91095bf294693acc..62447212d49324ce118705159472d45d8d0241d6 100644 (file)
@@ -584,6 +584,15 @@ diagnostic_classify_diagnostic (diagnostic_context *context,
     {
       int i;
 
+      /* Record the command-line status, so we can reset it back on DK_POP. */
+      if (old_kind == DK_UNSPECIFIED)
+       {
+         old_kind = context->option_enabled (option_index,
+                                             context->option_state)
+           ? DK_WARNING : DK_IGNORED;
+         context->classify_diagnostic[option_index] = old_kind;
+       }
+
       for (i = context->n_classification_history - 1; i >= 0; i --)
        if (context->classification_history[i].option == option_index)
          {
index 007a546e3888168dc775727cefbace4980287b48..3b9420161839dceb2dfcaa529c719d61b50bd2d7 100644 (file)
@@ -1119,6 +1119,9 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
   if (!flag_var)
     return;
 
+  if ((diagnostic_t) kind != DK_UNSPECIFIED && dc != NULL)
+    diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc);
+
   if (opts_set != NULL)
     set_flag_var = option_flag_var (opt_index, opts_set);
 
@@ -1198,10 +1201,6 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
        }
        break;
     }
-
-  if ((diagnostic_t) kind != DK_UNSPECIFIED
-      && dc != NULL)
-    diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc);
 }
 
 /* Return the address of the flag variable for option OPT_INDEX in
index 2e023a88fbbb6b352ae59b072d1197b8eec49e6e..73390a2cd50ec1aa6ae788780903080dfb20fcb3 100644 (file)
@@ -1,3 +1,11 @@
+2014-08-20  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c/59304
+       * opts-common.c (set_option): Call diagnostic_classify_diagnostic
+       before setting the option.
+       * diagnostic.c (diagnostic_classify_diagnostic): Record
+       command-line status.
+
 2014-08-20  Mark Wielaard  <mjw@redhat.com>
 
        * gcc.dg/guality/restrict.c: Add `used' attribute to all variables.
diff --git a/gcc/testsuite/gcc.dg/pr59304.c b/gcc/testsuite/gcc.dg/pr59304.c
new file mode 100644 (file)
index 0000000..f56ebc3
--- /dev/null
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+enum EE
+  {
+    ONE, TWO, THREE
+  };
+
+int f (enum EE e)
+{
+  int r = 0;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic error "-Wswitch-enum"
+
+  switch (e)
+    {
+    case ONE:
+      r = 1;
+      break;
+    case TWO:
+      r = 2;
+      break;
+    case THREE:
+      r = 3;
+      break;
+    }
+
+#pragma GCC diagnostic pop
+
+  switch (e)
+    {
+    case ONE:
+      r = 1;
+      break;
+    case TWO:
+      r = 2;
+      break;
+    }
+
+  return r;
+}