http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59304

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Actually, no need to undo, the patch below seems to do the trick. The idea is
that when we see a change of classification, and the option was originally
unspecified, we record the command-line status. This way later, when doing pop,
we already check if the option was reclassified so we get the command-line
status. This also works with -Wall, since all dependent options go through
set_option and call diagnostic_classify_diagnostic. But we have to call it
before changing the option status.


Index: opts-common.c
===================================================================
--- opts-common.c       (revision 205036)
+++ opts-common.c       (working copy)
@@ -1106,10 +1106,13 @@ set_option (struct gcc_options *opts, st
   void *set_flag_var = NULL;

   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);

   switch (option->var_type)
     {
@@ -1185,14 +1188,10 @@ set_option (struct gcc_options *opts, st
          if (set_flag_var)
            *(void **) set_flag_var = v;
        }
        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
    options structure OPTS, or NULL if there is no flag variable.  */

Index: diagnostic.c
===================================================================
--- diagnostic.c        (revision 205036)
+++ diagnostic.c        (working copy)
@@ -576,10 +576,19 @@ diagnostic_classify_diagnostic (diagnost
      the pragmas were.  */
   if (where != UNKNOWN_LOCATION)
     {
       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)
          {
            old_kind = context->classification_history[i].kind;
            break;

Reply via email to