Skip to content

Commit 5bd87e6

Browse files
authored
[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.
1 parent 19b65a9 commit 5bd87e6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4817,8 +4817,8 @@ Symbol &DeclarationVisitor::HandleAttributeStmt(
48174817
symbol = &MakeSymbol(name, EntityDetails{});
48184818
}
48194819
if (CheckDuplicatedAttr(name.source, *symbol, attr)) {
4820+
HandleSaveName(name.source, Attrs{attr});
48204821
SetExplicitAttr(*symbol, attr);
4821-
symbol->attrs() = HandleSaveName(name.source, symbol->attrs());
48224822
}
48234823
return *symbol;
48244824
}

flang/test/Semantics/resolve107.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ subroutine saves
99
!CHECK: SAVE attribute was already specified on 'x'
1010
!CHECK: SAVE attribute was already specified on 'z'
1111
save x,z
12+
save :: p
13+
procedure() :: p
14+
!CHECK-NOT: SAVE attribute was already specified on 'p'
15+
pointer :: p
1216
end
13-

0 commit comments

Comments
 (0)