[flang-commits] [flang] 0f500d3 - [flang] Downgrade benign error message to a warning
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jan 13 16:27:50 PST 2022
Author: Peter Klausler
Date: 2022-01-13T16:27:40-08:00
New Revision: 0f500d3dae705d37b35ec7002d67d001d9267e19
URL: https://github.com/llvm/llvm-project/commit/0f500d3dae705d37b35ec7002d67d001d9267e19
DIFF: https://github.com/llvm/llvm-project/commit/0f500d3dae705d37b35ec7002d67d001d9267e19.diff
LOG: [flang] Downgrade benign error message to a warning
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
Added:
flang/test/Semantics/resolve107.f90
Modified:
flang/docs/Extensions.md
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/resolve45.f90
Removed:
################################################################################
diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 5537bf487742..e58176e89bef 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -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
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 5b0b04093672..70cd23e557c5 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -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);
}
}
diff --git a/flang/test/Semantics/resolve107.f90 b/flang/test/Semantics/resolve107.f90
new file mode 100644
index 000000000000..2cc32a98c2fc
--- /dev/null
+++ b/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
+
diff --git a/flang/test/Semantics/resolve45.f90 b/flang/test/Semantics/resolve45.f90
index b3a09d243477..2402586fd4e1 100644
--- a/flang/test/Semantics/resolve45.f90
+++ b/flang/test/Semantics/resolve45.f90
@@ -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/
More information about the flang-commits
mailing list