[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@c39c7872d4
Reviewed-on: https://github.com/flang-compiler/f18/pull/687
This commit is contained in:
Tim Keith 2019-08-26 17:37:48 -07:00
parent 9de2bf6aa8
commit 396a659413
2 changed files with 19 additions and 1 deletions

View File

@ -4711,7 +4711,14 @@ const parser::Name *DeclarationVisitor::ResolveDataRef(
[=](const Indirection<parser::StructureComponent> &y) {
return ResolveStructureComponent(y.value());
},
[=](const auto &y) { return ResolveDataRef(y.value().base); },
[&](const common::Indirection<parser::ArrayElement> &y) {
Walk(y.value().subscripts);
return ResolveDataRef(y.value().base);
},
[&](const common::Indirection<parser::CoindexedNamedObject> &y) {
Walk(y.value().imageSelector);
return ResolveDataRef(y.value().base);
},
},
x.u);
}

View File

@ -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