[flang-commits] [flang] [flang] Set SAVE attribute for EQUIVALENCEd symbols consistently. (PR #67078)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Fri Sep 22 14:31:19 PDT 2023
================
@@ -2390,7 +2390,7 @@ Symbol &ScopeHandler::MakeHostAssocSymbol(
// These attributes can be redundantly reapplied without error
// on the host-associated name, at most once (C815).
symbol.implicitAttrs() =
- symbol.attrs() & Attrs{Attr::ASYNCHRONOUS, Attr::VOLATILE};
+ symbol.attrs() & Attrs{Attr::ASYNCHRONOUS, Attr::VOLATILE, Attr::SAVE};
----------------
vzakhari wrote:
I had to make this change to resolve the following issue:
```
subroutine host
integer :: x = 1
integer :: y
common /blk/ y
equivalence(x,y)
contains
subroutine inner
x = y
end subroutine inner
end subroutine host
```
Without propagating to the host-associated symbol the fact that `SAVE` is implicit, I would get this error:
```
./save.f90:8:5: error: The entity 'x' in COMMON block /blk/ may not have an explicit SAVE attribute
x = y
^
./save.f90:8:9: error: The entity 'y' in COMMON block /blk/ may not have an explicit SAVE attribute
x = y
^
bbc: semantic errors in save.f90
```
As you said, explicit `SAVE` statement in a nested scope will create a new symbol, so this code should not affect this case.
https://github.com/llvm/llvm-project/pull/67078
More information about the flang-commits
mailing list