aboutsummaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2023-07-19 13:56:32 -0700
committerPeter Klausler <pklausler@nvidia.com>2023-07-21 13:40:30 -0700
commit24445fc15ca451b9db5bc928a2b5bc9c8ef99792 (patch)
tree38368208d7c4ab300e3f3fd8461a038aa02f6755 /flang
parente7cb6778000bdc915508cbe06ff23d976a1e6a51 (diff)
downloadllvm-24445fc15ca451b9db5bc928a2b5bc9c8ef99792.zip
llvm-24445fc15ca451b9db5bc928a2b5bc9c8ef99792.tar.gz
llvm-24445fc15ca451b9db5bc928a2b5bc9c8ef99792.tar.bz2
[flang] Disallow ASYNCHRONOUS for subroutine
The check for inappropriate usage of the ASYNCHRONOUS attribute needed to be moved in declaration checking so that it can catch attempts to use it on a subroutine. Differential Revision: https://reviews.llvm.org/D155970
Diffstat (limited to 'flang')
-rw-r--r--flang/lib/Semantics/check-declarations.cpp11
-rw-r--r--flang/test/Semantics/resolve20.f902
2 files changed, 8 insertions, 5 deletions
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index ad94039..337f1a0 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -277,6 +277,12 @@ void CheckHelper::Check(const Symbol &symbol) {
CheckContiguous(symbol);
}
CheckGlobalName(symbol);
+ if (symbol.attrs().test(Attr::ASYNCHRONOUS) &&
+ !evaluate::IsVariable(symbol)) {
+ messages_.Say(
+ "An entity may not have the ASYNCHRONOUS attribute unless it is a variable"_err_en_US);
+ }
+
if (isDone) {
return; // following checks do not apply
}
@@ -429,11 +435,6 @@ void CheckHelper::Check(const Symbol &symbol) {
symbol.name());
}
}
- if (symbol.attrs().test(Attr::ASYNCHRONOUS) &&
- !evaluate::IsVariable(symbol)) {
- messages_.Say(
- "An entity may not have the ASYNCHRONOUS attribute unless it is a variable"_err_en_US);
- }
}
void CheckHelper::CheckCommonBlock(const Symbol &symbol) {
diff --git a/flang/test/Semantics/resolve20.f90 b/flang/test/Semantics/resolve20.f90
index 1f111bb..239e32b 100644
--- a/flang/test/Semantics/resolve20.f90
+++ b/flang/test/Semantics/resolve20.f90
@@ -81,7 +81,9 @@ module m
contains
subroutine bar
end subroutine
+ !ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable
subroutine test
+ asynchronous test
!ERROR: Abstract procedure interface 'foo2' may not be referenced
call foo2()
!ERROR: Abstract procedure interface 'f' may not be referenced