[flang-commits] [PATCH] D117153: [flang] Downgrade benign error message to a warning
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Jan 12 14:08:22 PST 2022
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a reviewer: sscalpone.
klausler requested review of this revision.
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.
https://reviews.llvm.org/D117153
Files:
flang/docs/Extensions.md
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve107.f90
flang/test/Semantics/resolve45.f90
Index: flang/test/Semantics/resolve45.f90
===================================================================
--- flang/test/Semantics/resolve45.f90
+++ flang/test/Semantics/resolve45.f90
@@ -53,17 +53,6 @@
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/
Index: flang/test/Semantics/resolve107.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/resolve107.f90
@@ -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
+
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -4809,7 +4809,7 @@
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);
}
}
Index: flang/docs/Extensions.md
===================================================================
--- flang/docs/Extensions.md
+++ flang/docs/Extensions.md
@@ -190,6 +190,8 @@
exactly one is unlimited polymorphic).
* External unit 0 is predefined and connected to the standard error output,
and defined as `ERROR_UNIT` in the intrinsic `ISO_FORTRAN_ENV` module.
+* Multiple specifications of the SAVE attribute on the same object
+ are allowed, with a warning.
### Extensions supported when enabled by options
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117153.399453.patch
Type: text/x-patch
Size: 2253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220112/0bfaa9dd/attachment.bin>
More information about the flang-commits
mailing list