[flang-commits] [flang] ed5a78a - [flang] Catch ASSOCIATE(x=>assumed_rank) (#100626)

via flang-commits flang-commits at lists.llvm.org
Tue Jul 30 09:44:12 PDT 2024


Author: Peter Klausler
Date: 2024-07-30T09:44:09-07:00
New Revision: ed5a78a13fb6c82e4bc8bde13df2fc5e085e6ebb

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

LOG: [flang] Catch ASSOCIATE(x=>assumed_rank) (#100626)

An assumed-rank dummy argument cannot be the variable or expression in
the selector of an ASSOCIATE construct. (SELECT TYPE/RANK are fine.)

Added: 
    flang/test/Semantics/associate04.f90

Modified: 
    flang/lib/Semantics/resolve-names.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 95d021e3aa647..b7725c5b00228 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -7121,9 +7121,13 @@ void ConstructVisitor::Post(const parser::AssociateStmt &x) {
   for (auto nthLastAssoc{assocCount}; nthLastAssoc > 0; --nthLastAssoc) {
     SetCurrentAssociation(nthLastAssoc);
     if (auto *symbol{MakeAssocEntity()}) {
-      if (ExtractCoarrayRef(GetCurrentAssociation().selector.expr)) { // C1103
+      const MaybeExpr &expr{GetCurrentAssociation().selector.expr};
+      if (ExtractCoarrayRef(expr)) { // C1103
         Say("Selector must not be a coindexed object"_err_en_US);
       }
+      if (evaluate::IsAssumedRank(expr)) {
+        Say("Selector must not be assumed-rank"_err_en_US);
+      }
       SetTypeFromAssociation(*symbol);
       SetAttrsFromAssociation(*symbol);
     }

diff  --git a/flang/test/Semantics/associate04.f90 b/flang/test/Semantics/associate04.f90
new file mode 100644
index 0000000000000..5a73ba419c0a3
--- /dev/null
+++ b/flang/test/Semantics/associate04.f90
@@ -0,0 +1,7 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+subroutine bad(a)
+  real :: a(..)
+  !ERROR: Selector must not be assumed-rank
+  associate(x => a)
+  end associate
+end subroutine


        


More information about the flang-commits mailing list