[flang-commits] [flang] [flang] Silence spurious errors about SAVE (PR #78765)
via flang-commits
flang-commits at lists.llvm.org
Fri Jan 19 11:26:48 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
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
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
-
``````````
</details>
https://github.com/llvm/llvm-project/pull/78765
More information about the flang-commits
mailing list