https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102831

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
I have been testing the following changes to deal with other location and
warning related problems.  They might be worth giving a try to see if they help
with this issue as well. 

diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c
index 85ffb725c02..09fd42bcf53 100644
--- a/gcc/diagnostic-spec.c
+++ b/gcc/diagnostic-spec.c
@@ -186,11 +186,8 @@ copy_warning (location_t to, location_t from)
     /* We cannot set no-warning dispositions for 'to', so we have no chance
but
        lose those potentially set for 'from'.  */
     ;
-  else
-    {
-      if (from_spec)
-       nowarn_map->put (to, *from_spec);
-      else
-       nowarn_map->remove (to);
-    }
+  else if (from_spec)
+    nowarn_map->put (to, *from_spec);
+  /* ...else keep the entry since it may be referenced by multiple trees
+     or GIMPLE statements at this location.  */
 }
diff --git a/gcc/warning-control.cc b/gcc/warning-control.cc
index 36a47ab6bae..e490bf28b24 100644
--- a/gcc/warning-control.cc
+++ b/gcc/warning-control.cc
@@ -198,21 +198,13 @@ void copy_warning (ToType to, FromType from)
     /* We cannot set no-warning dispositions for 'to', so we have no chance
but
        lose those potentially set for 'from'.  */
     ;
-  else
+  else if (from_spec)
     {
-      if (from_spec)
-       {
-         /* If there's an entry in the map the no-warning bit must be set.  */
-         gcc_assert (supp);
-
-         gcc_checking_assert (nowarn_map);
-         nowarn_map->put (to_loc, *from_spec);
-       }
-      else
-       {
-         if (nowarn_map)
-           nowarn_map->remove (to_loc);
-       }
+      /* If there's an entry in the map the no-warning bit must be set.  */
+      gcc_assert (supp);
+
+      gcc_checking_assert (nowarn_map);
+      nowarn_map->put (to_loc, *from_spec);
     }

   /* The no-warning bit might be set even if the map has not been consulted,
or

Reply via email to