From 24445fc15ca451b9db5bc928a2b5bc9c8ef99792 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Wed, 19 Jul 2023 13:56:32 -0700 Subject: [PATCH] [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 --- flang/lib/Semantics/check-declarations.cpp | 11 ++++++----- flang/test/Semantics/resolve20.f90 | 2 ++ 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 -- 2.7.4