Skip to content

Commit

Permalink
[flang] Downgrade benign error message to a warning
Browse files Browse the repository at this point in the history
It's not conforming to specify the SAVE attribute more than
once for a variable, but it also doesn't hurt anything and
isn't fatal in other Fortran compilers.  Downgrade the
message to a warning for better portability.

Differential Revision: https://reviews.llvm.org/D117153
  • Loading branch information
klausler committed Jan 14, 2022
1 parent 073c27b commit 0f500d3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions flang/docs/Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ end
* External unit 0 is predefined and connected to the standard error output,
and defined as `ERROR_UNIT` in the intrinsic `ISO_FORTRAN_ENV` module.
* Objects in blank COMMON may be initialized.
* Multiple specifications of the SAVE attribute on the same object
are allowed, with a warning.

### Extensions supported when enabled by options

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4903,7 +4903,7 @@ void DeclarationVisitor::AddSaveName(
std::set<SourceName> &set, const SourceName &name) {
auto pair{set.insert(name)};
if (!pair.second) {
Say2(name, "SAVE attribute was already specified on '%s'"_err_en_US,
Say2(name, "SAVE attribute was already specified on '%s'"_en_US,
*pair.first, "Previous specification of SAVE attribute"_en_US);
}
}
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Semantics/resolve107.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
! RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s
! Check warning on multiple SAVE attribute specifications
subroutine saves
save x
save y
!CHECK: SAVE attribute was already specified on 'y'
integer, save :: y
integer, save :: z
!CHECK: SAVE attribute was already specified on 'x'
!CHECK: SAVE attribute was already specified on 'z'
save x,z
end

11 changes: 0 additions & 11 deletions flang/test/Semantics/resolve45.f90
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ subroutine s5
end block
end

subroutine s6
save x
save y
!ERROR: SAVE attribute was already specified on 'y'
integer, save :: y
integer, save :: z
!ERROR: SAVE attribute was already specified on 'x'
!ERROR: SAVE attribute was already specified on 'z'
save x,z
end

subroutine s7
!ERROR: 'x' appears as a COMMON block in a SAVE statement but not in a COMMON statement
save /x/
Expand Down

0 comments on commit 0f500d3

Please sign in to comment.