[flang-commits] [PATCH] D87073: [flang]Fix for PR47339

Inderjeet via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Sep 3 20:29:08 PDT 2020


inderjeet-hcl updated this revision to Diff 289846.
inderjeet-hcl added a comment.

Modified resolve-names.cpp to incorporate review comments. Also, removed comment related to C1103 from tools.cpp.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87073/new/

https://reviews.llvm.org/D87073

Files:
  flang/lib/Semantics/resolve-names.cpp
  flang/lib/Semantics/tools.cpp
  flang/test/Semantics/resolve95.f90


Index: flang/test/Semantics/resolve95.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/resolve95.f90
@@ -0,0 +1,15 @@
+! RUN: %S/test_errors.sh %s %t %f18
+! Test SELECT TYPE and ASSOCIATE errors: C1103
+
+subroutine s1()
+  class(*),allocatable :: calc[:]
+  integer,save :: icoa[*]
+  !ERROR: Selector must not be a coindexed object
+  associate(sel=>icoa[2])
+  end associate
+  icoa = 2
+  allocate(integer::calc[*])
+  !ERROR: Selector must not be a coindexed object
+  select type(sel=>calc[2])
+  end select
+end subroutine
Index: flang/lib/Semantics/tools.cpp
===================================================================
--- flang/lib/Semantics/tools.cpp
+++ flang/lib/Semantics/tools.cpp
@@ -739,7 +739,6 @@
 }
 
 // C1101 and C1158
-// TODO Need to check for a coindexed object (why? C1103?)
 std::optional<parser::MessageFixedText> WhyNotModifiable(
     const Symbol &symbol, const Scope &scope) {
   const Symbol *root{GetAssociationRoot(symbol)};
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -5044,6 +5044,9 @@
   const auto &name{std::get<parser::Name>(x.t)};
   GetCurrentAssociation().name = &name;
   if (auto *symbol{MakeAssocEntity()}) {
+    if (ExtractCoarrayRef(GetCurrentAssociation().selector.expr)) { // C1103
+      Say("Selector must not be a coindexed object"_err_en_US);
+    }
     SetTypeFromAssociation(*symbol);
     SetAttrsFromAssociation(*symbol);
   }
@@ -5098,6 +5101,9 @@
     MakePlaceholder(*name, MiscDetails::Kind::SelectTypeAssociateName);
     association.name = &*name;
     auto exprType{association.selector.expr->GetType()};
+    if (ExtractCoarrayRef(association.selector.expr)) { // C1103
+      Say("Selector must not be a coindexed object"_err_en_US);
+    }
     if (exprType && !exprType->IsPolymorphic()) { // C1159
       Say(association.selector.source,
           "Selector '%s' in SELECT TYPE statement must be "


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87073.289846.patch
Type: text/x-patch
Size: 2098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20200904/8d61d21f/attachment.bin>


More information about the flang-commits mailing list