[flang-commits] [PATCH] D146573: [flang] Catch attempt to apply ASYNCHRONOUS attribute to a non-variable

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Mar 21 15:03:33 PDT 2023


klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

Complain about the ASYNCHRONOUS attribute on symbols that aren't
variables.


https://reviews.llvm.org/D146573

Files:
  flang/lib/Semantics/check-declarations.cpp
  flang/test/Semantics/resolve20.f90


Index: flang/test/Semantics/resolve20.f90
===================================================================
--- flang/test/Semantics/resolve20.f90
+++ flang/test/Semantics/resolve20.f90
@@ -53,6 +53,10 @@
   !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'
Index: flang/lib/Semantics/check-declarations.cpp
===================================================================
--- flang/lib/Semantics/check-declarations.cpp
+++ flang/lib/Semantics/check-declarations.cpp
@@ -428,6 +428,11 @@
         " of a module"_err_en_US,
         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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146573.507139.patch
Type: text/x-patch
Size: 1107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230321/4a78eb83/attachment-0001.bin>


More information about the flang-commits mailing list