Skip to content

Commit 0a79113

Browse files
committed
[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
1 parent d52a6e7 commit 0a79113

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

flang/lib/Semantics/runtime-type-info.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ class RuntimeTableBuilder {
103103
lenParameterEnum_, FindLenParameterIndex(*parameters, *lenParam));
104104
}
105105
}
106+
// TODO: Replace a specification expression requiring actual operations
107+
// with a reference to a new anonymous LEN type parameter whose default
108+
// value captures the expression. This replacement must take place when
109+
// the type is declared so that the new LEN type parameters appear in
110+
// all instantiations and structure constructors.
106111
context_.Say(location_,
107-
"Specification expression '%s' is neither constant nor a length "
108-
"type parameter"_err_en_US,
112+
"derived type specification expression '%s' that is neither constant nor a length type parameter"_todo_en_US,
109113
expr->AsFortran());
110114
}
111115
return PackageIntValue(deferredEnum_);
@@ -734,7 +738,7 @@ evaluate::StructureConstructor RuntimeTableBuilder::DescribeComponent(
734738
evaluate::Extremum<evaluate::SubscriptInteger>>(*len)}) {
735739
if (clamped->ordering == evaluate::Ordering::Greater &&
736740
clamped->left() == evaluate::Expr<evaluate::SubscriptInteger>{0}) {
737-
len = clamped->right();
741+
len = common::Clone(clamped->right());
738742
}
739743
}
740744
AddValue(values, componentSchema_, "characterlen"s,

0 commit comments

Comments
 (0)