[flang] Fix bug checking SAVE attribute

Treat function result like dummy argument: a SAVE statement without an
entity-list does not make it saved.

Differential Revision: https://reviews.llvm.org/D82309
This commit is contained in:
Tim Keith 2020-06-22 11:32:54 -07:00
parent 809bcf4c87
commit 663860f63e
2 changed files with 9 additions and 2 deletions

View File

@ -1003,7 +1003,7 @@ bool IsSaved(const Symbol &original) {
} else if (const Symbol * block{FindCommonBlockContaining(symbol)};
block && block->attrs().test(Attr::SAVE)) {
return true;
} else if (IsDummy(symbol)) {
} else if (IsDummy(symbol) || IsFunctionResult(symbol)) {
return false;
} else {
for (; !scope->IsGlobal(); scope = &scope->parent()) {

View File

@ -15,8 +15,15 @@ function f2(x, y)
!ERROR: SAVE attribute may not be applied to dummy argument 'x'
complex, save :: x
allocatable :: y
integer :: y
!ERROR: SAVE attribute may not be applied to dummy argument 'y'
integer, save :: y
save :: y
end
! SAVE statement should not trigger the above errors
function f2b(x, y)
real :: x, y
save
end
subroutine s3(x)