[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.
This commit is contained in:
Peter Klausler
2024-01-25 15:33:26 -08:00
committed by GitHub
parent 19b65a9c02
commit 5bd87e65d6
2 changed files with 5 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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