[flang-commits] [flang] 24445fc - [flang] Disallow ASYNCHRONOUS for subroutine

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Fri Jul 21 13:51:54 PDT 2023


Author: Peter Klausler
Date: 2023-07-21T13:40:30-07:00
New Revision: 24445fc15ca451b9db5bc928a2b5bc9c8ef99792

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

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

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 ad940394375036..337f1a0b593017 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 1f111bb9ef0d2a..239e32ba92a497 100644
--- a/flang/test/Semantics/resolve20.f90
+++ b/flang/test/Semantics/resolve20.f90
@@ -81,7 +81,9 @@ function f()
 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


        


More information about the flang-commits mailing list