[flang-commits] [flang] [flang] Silence spurious errors about SAVE (PR #78765)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Jan 19 11:26:16 PST 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/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.
>From 1e327624185fcdd063cda5129366358253783ac2 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 19 Jan 2024 11:21:53 -0800
Subject: [PATCH] [flang] Silence spurious errors about SAVE
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.
---
flang/lib/Semantics/resolve-names.cpp | 2 +-
flang/test/Semantics/resolve107.f90 | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
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