From fe8abccbcd473ce9d6b695a31e16519df1499faf Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Tue, 14 Mar 2023 13:10:25 -0700 Subject: [PATCH] [flang] Catch attempt to apply ASYNCHRONOUS attribute to a non-variable Complain about the ASYNCHRONOUS attribute on symbols that aren't variables. Differential Revision: https://reviews.llvm.org/D146573 --- flang/lib/Semantics/check-declarations.cpp | 5 +++++ flang/test/Semantics/resolve20.f90 | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp index 3a462d1..0be05e6 100644 --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -437,6 +437,11 @@ 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 a0870de..1f111bb 100644 --- a/flang/test/Semantics/resolve20.f90 +++ b/flang/test/Semantics/resolve20.f90 @@ -54,6 +54,10 @@ module m !ERROR: EXTERNAL attribute not allowed on 'bar' external :: bar + !ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable + asynchronous :: async + external :: async + !ERROR: PARAMETER attribute not allowed on 'm' parameter(m=2) !ERROR: PARAMETER attribute not allowed on 'foo' -- 2.7.4