[flang] Replace crash and improve a semantics TODO message

The derived type information table construction code had a
crash whose root cause was replacing an expression with one
of its operands -- the deletion of the LHS of that assignment
led to the RHS being invalidated before it could be read.
Fix by cloning the RHS.  Also update a TODO message to the
new "_todo_en_US" message class and add a comment about how
it should be resolved.

Differential Revision: https://reviews.llvm.org/D126154
This commit is contained in:
Peter Klausler 2022-05-20 14:21:59 -07:00
parent d52a6e75b0
commit 0a79113b9e
1 changed files with 7 additions and 3 deletions

View File

@ -103,9 +103,13 @@ private:
lenParameterEnum_, FindLenParameterIndex(*parameters, *lenParam));
}
}
// TODO: Replace a specification expression requiring actual operations
// with a reference to a new anonymous LEN type parameter whose default
// value captures the expression. This replacement must take place when
// the type is declared so that the new LEN type parameters appear in
// all instantiations and structure constructors.
context_.Say(location_,
"Specification expression '%s' is neither constant nor a length "
"type parameter"_err_en_US,
"derived type specification expression '%s' that is neither constant nor a length type parameter"_todo_en_US,
expr->AsFortran());
}
return PackageIntValue(deferredEnum_);
@ -734,7 +738,7 @@ evaluate::StructureConstructor RuntimeTableBuilder::DescribeComponent(
evaluate::Extremum<evaluate::SubscriptInteger>>(*len)}) {
if (clamped->ordering == evaluate::Ordering::Greater &&
clamped->left() == evaluate::Expr<evaluate::SubscriptInteger>{0}) {
len = clamped->right();
len = common::Clone(clamped->right());
}
}
AddValue(values, componentSchema_, "characterlen"s,