If we fail to evaluate the kind expression we were getting an invalid
optional reference. Instead, fail with an assert. This can happen if an
intrinsic function is not folded, but that will be implemented
eventually.
Original-commit: flang-compiler/f18@
3bdbfc34bb75e6585eea57aa3240c3c825fff704
Reviewed-on: https://github.com/flang-compiler/f18/pull/256
Tree-same-pre-rewrite: false
}
void DeclarationVisitor::Post(const parser::CharSelector::LengthAndKind &x) {
if (auto maybeExpr{EvaluateExpr(x.kind)}) {
- charInfo_.kind = evaluate::ToInt64(*maybeExpr).value();
+ if (std::optional<std::int64_t> kind{evaluate::ToInt64(*maybeExpr)}) {
+ charInfo_.kind = *kind;
+ } else {
+ common::die("TODO: kind did not evaluate to a constant integer");
+ }
}
if (x.length) {
charInfo_.length = GetParamValue(*x.length);