[flang] Allow for vector subscript on LHS of assignment
authorTim Keith <tkeith@nvidia.com>
Tue, 10 Mar 2020 23:32:58 +0000 (16:32 -0700)
committerTim Keith <tkeith@nvidia.com>
Tue, 10 Mar 2020 23:32:58 +0000 (16:32 -0700)
Original-commit: flang-compiler/f18@38aefd41f051546024ecf4555a3bb3385b99f3c7
Reviewed-on: https://github.com/flang-compiler/f18/pull/1062

flang/lib/Semantics/assignment.cpp
flang/test/Semantics/assign04.f90

index bd8fe2c..18f0ffc 100644 (file)
@@ -73,7 +73,7 @@ void AssignmentContext::Analyze(const parser::AssignmentStmt &stmt) {
     }
     if (CheckForPureContext(lhs, rhs, rhsLoc, false)) {
       const Scope &scope{context_.FindScope(lhsLoc)};
-      if (auto whyNot{WhyNotModifiable(lhsLoc, lhs, scope)}) {
+      if (auto whyNot{WhyNotModifiable(lhsLoc, lhs, scope, true)}) {
         if (auto *msg{Say(lhsLoc,
                 "Left-hand side of assignment is not modifiable"_err_en_US)}) {
           msg->Attach(*whyNot);
index e0a0216..b4214a4 100644 (file)
@@ -108,3 +108,8 @@ contains
     x%i = [1, 2, 3]
   end
 end
+
+subroutine s7
+  integer :: a(10), v(10)
+  a(v(:)) = 1  ! vector subscript is ok
+end