From 396a659413e07344c1825ab28a514a43cc73ed03 Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Mon, 26 Aug 2019 17:37:48 -0700 Subject: [PATCH] [flang] Resolve index in pointer assignment to array element When the LHS of a pointer assignment is an array element, the index must be resolved. Fixed flang-compiler/f18#684. Original-commit: flang-compiler/f18@c39c7872d42e3490a2c862771893d3099202df63 Reviewed-on: https://github.com/flang-compiler/f18/pull/687 --- flang/lib/semantics/resolve-names.cc | 9 ++++++++- flang/test/semantics/resolve49.f90 | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc index 4b686f016f7e..fddef79262a9 100644 --- a/flang/lib/semantics/resolve-names.cc +++ b/flang/lib/semantics/resolve-names.cc @@ -4711,7 +4711,14 @@ const parser::Name *DeclarationVisitor::ResolveDataRef( [=](const Indirection &y) { return ResolveStructureComponent(y.value()); }, - [=](const auto &y) { return ResolveDataRef(y.value().base); }, + [&](const common::Indirection &y) { + Walk(y.value().subscripts); + return ResolveDataRef(y.value().base); + }, + [&](const common::Indirection &y) { + Walk(y.value().imageSelector); + return ResolveDataRef(y.value().base); + }, }, x.u); } diff --git a/flang/test/semantics/resolve49.f90 b/flang/test/semantics/resolve49.f90 index 8d98d54f5f3b..9d03b667df29 100644 --- a/flang/test/semantics/resolve49.f90 +++ b/flang/test/semantics/resolve49.f90 @@ -45,3 +45,14 @@ program p3 a(n:,n:) => b a(1:n,1:n) => b end + +! Test pointer assignment to array element +program p4 + type :: t + real, pointer :: a + end type + type(t) :: x(10) + integer :: i + real, target :: y + x(i)%a => y +end program