summaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2023-05-09 14:41:32 -0700
committerPeter Klausler <pklausler@nvidia.com>2023-05-16 14:01:24 -0700
commit28cc9606c0b4a70f26b4a3eea32cf88c330b2d82 (patch)
tree48264fe5c0b066e6db423e999bc6765481176306 /flang
parent191d48723f8b853a6ad65532c173c67155cbe606 (diff)
downloadllvm-28cc9606c0b4a70f26b4a3eea32cf88c330b2d82.tar.gz
[flang] Fix bogus errors about CONTIGUOUS attribute
Incorrect error messages were issuing for symbol table entries with the CONTIGUOUS attribute that didn't deserve them, like host association symbols. Put the CONTIGUOUS check into CheckObjectEntity(). Differential Revision: https://reviews.llvm.org/D150712
Diffstat (limited to 'flang')
-rw-r--r--flang/lib/Semantics/check-declarations.cpp24
-rw-r--r--flang/test/Semantics/resolve14.f906
2 files changed, 17 insertions, 13 deletions
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 3162af396efc..1b9a747501ed 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -261,19 +261,6 @@ void CheckHelper::Check(const Symbol &symbol) {
CheckExplicitSave(symbol);
}
const auto *object{symbol.detailsIf<ObjectEntityDetails>()};
- if (symbol.attrs().test(Attr::CONTIGUOUS)) {
- if ((!object && !symbol.has<UseDetails>()) ||
- !((IsPointer(symbol) && symbol.Rank() > 0) || IsAssumedShape(symbol) ||
- evaluate::IsAssumedRank(symbol))) {
- if (symbol.owner().IsDerivedType()) { // C752
- messages_.Say(
- "A CONTIGUOUS component must be an array with the POINTER attribute"_err_en_US);
- } else { // C830
- messages_.Say(
- "CONTIGUOUS entity must be an array pointer, assumed-shape, or assumed-rank"_err_en_US);
- }
- }
- }
CheckGlobalName(symbol);
if (isDone) {
return; // following checks do not apply
@@ -848,6 +835,17 @@ void CheckHelper::CheckObjectEntity(
"'%s' is a data object and may not be EXTERNAL"_err_en_US,
symbol.name());
}
+ if (symbol.attrs().test(Attr::CONTIGUOUS)) {
+ if ((IsPointer(symbol) && symbol.Rank() > 0) || IsAssumedShape(symbol) ||
+ evaluate::IsAssumedRank(symbol)) {
+ } else if (symbol.owner().IsDerivedType()) { // C752
+ messages_.Say(
+ "A CONTIGUOUS component must be an array with the POINTER attribute"_err_en_US);
+ } else { // C830
+ messages_.Say(
+ "CONTIGUOUS entity must be an array pointer, assumed-shape, or assumed-rank"_err_en_US);
+ }
+ }
}
void CheckHelper::CheckPointerInitialization(const Symbol &symbol) {
diff --git a/flang/test/Semantics/resolve14.f90 b/flang/test/Semantics/resolve14.f90
index 78b80ae8de93..aae2145ff9cc 100644
--- a/flang/test/Semantics/resolve14.f90
+++ b/flang/test/Semantics/resolve14.f90
@@ -27,6 +27,12 @@ program p2
contiguous w
!ERROR: 'z' is use-associated from module 'm2' and cannot be re-declared
integer z
+ real, target :: a(10)
+ real, contiguous, pointer :: p(:) => a
!ERROR: Reference to 'y' is ambiguous
y = 1
+ contains
+ subroutine inner
+ p(1) = 0. ! ok - check for regression on contiguous host assoc.
+ end subroutine
end