[flang-commits] [flang] fe8abcc - [flang] Catch attempt to apply ASYNCHRONOUS attribute to a non-variable

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Mar 27 15:14:54 PDT 2023


Author: Peter Klausler
Date: 2023-03-27T15:14:44-07:00
New Revision: fe8abccbcd473ce9d6b695a31e16519df1499faf

URL: https://github.com/llvm/llvm-project/commit/fe8abccbcd473ce9d6b695a31e16519df1499faf
DIFF: https://github.com/llvm/llvm-project/commit/fe8abccbcd473ce9d6b695a31e16519df1499faf.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 3a462d19ed83..0be05e699091 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 a0870de7b82f..1f111bb9ef0d 100644
--- a/flang/test/Semantics/resolve20.f90
+++ b/flang/test/Semantics/resolve20.f90
@@ -54,6 +54,10 @@ subroutine forward
   !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'


        


More information about the flang-commits mailing list