Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang] Silence spurious errors about SAVE #78765

Merged
merged 1 commit into from
Jan 25, 2024
Merged

Conversation

klausler
Copy link
Contributor

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.

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.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jan 19, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 19, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/78765.diff

2 Files Affected:

  • (modified) flang/lib/Semantics/resolve-names.cpp (+1-1)
  • (modified) flang/test/Semantics/resolve107.f90 (+4-1)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index e4a841ec28486c4..000cf7f79a422d3 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 2cc32a98c2fccc9..79ee013d257c789 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
-

@klausler klausler merged commit 5bd87e6 into llvm:main Jan 25, 2024
6 checks passed
@klausler klausler deleted the procptr9 branch January 25, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants