[flang-commits] [flang] 5bd87e6 - [flang] Silence spurious errors about SAVE (#78765)

via flang-commits flang-commits at lists.llvm.org
Thu Jan 25 15:33:30 PST 2024


Author: Peter Klausler
Date: 2024-01-25T15:33:26-08:00
New Revision: 5bd87e65d6a3f985471058ee071320c1def718c4

URL: https://github.com/llvm/llvm-project/commit/5bd87e65d6a3f985471058ee071320c1def718c4
DIFF: https://github.com/llvm/llvm-project/commit/5bd87e65d6a3f985471058ee071320c1def718c4.diff

LOG: [flang] Silence spurious errors about SAVE (#78765)

When an attribute specification statement follows a declaration that
applies the SAVE attribute to a symbol, name resolution can produce a
spurious error message about redundant SAVEs.

Fixes llvm-test-suite/Fortran/gfortran/regression/proc_ptr_9.f90.

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp
    flang/test/Semantics/resolve107.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index e4a841ec28486c..000cf7f79a422d 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -4817,8 +4817,8 @@ Symbol &DeclarationVisitor::HandleAttributeStmt(
     symbol = &MakeSymbol(name, EntityDetails{});
   }
   if (CheckDuplicatedAttr(name.source, *symbol, attr)) {
+    HandleSaveName(name.source, Attrs{attr});
     SetExplicitAttr(*symbol, attr);
-    symbol->attrs() = HandleSaveName(name.source, symbol->attrs());
   }
   return *symbol;
 }

diff  --git a/flang/test/Semantics/resolve107.f90 b/flang/test/Semantics/resolve107.f90
index 2cc32a98c2fccc..79ee013d257c78 100644
--- a/flang/test/Semantics/resolve107.f90
+++ b/flang/test/Semantics/resolve107.f90
@@ -9,5 +9,8 @@ subroutine saves
   !CHECK: SAVE attribute was already specified on 'x'
   !CHECK: SAVE attribute was already specified on 'z'
   save x,z
+  save :: p
+  procedure() :: p
+  !CHECK-NOT: SAVE attribute was already specified on 'p'
+  pointer :: p
 end
-


        


More information about the flang-commits mailing list