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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
                 CC|                            |kargl at gcc dot gnu.org
   Last reconfirmed|                            |2022-02-21
     Ever confirmed|0                           |1

--- Comment #1 from kargl at gcc dot gnu.org ---
NULL pointer deference.  While here, fix formatting.

diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 7a80dfd063b..a1580708f89 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -1299,9 +1299,8 @@ gfc_add_save (symbol_attribute *attr, save_state s, const
char *name,

   if (s == SAVE_EXPLICIT && gfc_pure (NULL))
     {
-      gfc_error
-       ("SAVE attribute at %L cannot be specified in a PURE procedure",
-        where);
+      gfc_error ("SAVE attribute at %L cannot be specified in a PURE "
+                "procedure", where);
       return false;
     }

@@ -1311,10 +1310,15 @@ gfc_add_save (symbol_attribute *attr, save_state s,
const char *name,
   if (s == SAVE_EXPLICIT && attr->save == SAVE_EXPLICIT
       && (flag_automatic || pedantic))
     {
-       if (!gfc_notify_std (GFC_STD_LEGACY,
-                            "Duplicate SAVE attribute specified at %L",
-                            where))
+      if (!where)
+       {
+         gfc_error ("Duplicate SAVE attribute specified near %C");
          return false;
+       }
+
+      if (!gfc_notify_std (GFC_STD_LEGACY, "Duplicate SAVE attribute "
+                          "specified at %L", where))
+       return false;
     }

   attr->save = s;

Reply via email to