[flang] Improve error message (add types)

Original-commit: flang-compiler/f18@48b8f32d51
Reviewed-on: https://github.com/flang-compiler/f18/pull/738
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-09-11 16:48:03 -07:00
parent ea7652a251
commit c93ceeeef7
1 changed files with 10 additions and 2 deletions

View File

@ -497,8 +497,16 @@ std::optional<Expr<LogicalResult>> Relate(parser::ContextualMessages &messages,
// Default case
[&](auto &&, auto &&) {
// TODO: defined operator
messages.Say(
"relational operands do not have comparable types"_err_en_US);
auto xtype{x.GetType()};
auto ytype{y.GetType()};
if (xtype.has_value() && ytype.has_value()) {
messages.Say(
"Relational operands do not have comparable types (%s vs. %s)"_err_en_US,
xtype->AsFortran(), ytype->AsFortran());
} else {
messages.Say(
"Relational operands do not have comparable types"_err_en_US);
}
return std::optional<Expr<LogicalResult>>{};
},
},