[flang] fix bug found in testing

Original-commit: flang-compiler/f18@297ad78510
Reviewed-on: https://github.com/flang-compiler/f18/pull/390
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-04-08 16:57:30 -07:00
parent 8057a2ce32
commit 3230a2f3ce
1 changed files with 6 additions and 7 deletions

View File

@ -88,8 +88,8 @@ bool DoConstruct::IsDoConcurrent() const {
}
static Designator MakeArrayElementRef(
const Name &name, std::list<Expr> &subscripts) {
ArrayElement arrayElement{Name{name.source}, std::list<SectionSubscript>{}};
const Name &name, std::list<Expr> &&subscripts) {
ArrayElement arrayElement{DataRef{Name{name}}, std::list<SectionSubscript>{}};
for (Expr &expr : subscripts) {
arrayElement.subscripts.push_back(SectionSubscript{
Scalar{Integer{common::Indirection{std::move(expr)}}}});
@ -124,7 +124,7 @@ Designator FunctionReference::ConvertToArrayElementRef() {
for (auto &arg : std::get<std::list<ActualArgSpec>>(v.t)) {
args.emplace_back(std::move(ActualArgToExpr(name.source, arg).value()));
}
return MakeArrayElementRef(name, args);
return MakeArrayElementRef(name, std::move(args));
}
StructureConstructor FunctionReference::ConvertToStructureConstructor(
@ -163,11 +163,10 @@ Statement<ActionStmt> StmtFunctionStmt::ConvertToAssignment() {
auto &funcExpr{std::get<Scalar<Expr>>(t).thing};
std::list<Expr> subscripts;
for (Name &arg : funcArgs) {
subscripts.push_back(
Expr{common::Indirection{Designator{Name{arg.source}}}});
subscripts.push_back(Expr{common::Indirection{Designator{Name{arg}}}});
}
auto variable{
Variable{common::Indirection{MakeArrayElementRef(funcName, subscripts)}}};
auto variable{Variable{common::Indirection{
MakeArrayElementRef(funcName, std::move(subscripts))}}};
return Statement{std::nullopt,
ActionStmt{common::Indirection{
AssignmentStmt{std::move(variable), std::move(funcExpr)}}}};