[flang] Ensure no failed expression analyses without fatal errors.

Original-commit: flang-compiler/f18@3ef8b43031
Reviewed-on: https://github.com/flang-compiler/f18/pull/406
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-04-12 11:43:03 -07:00
parent 8529034ea0
commit a90455057c
2 changed files with 6 additions and 0 deletions

View File

@ -1832,6 +1832,9 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::Expr &expr) {
} }
if (result.has_value()) { if (result.has_value()) {
expr.typedExpr.reset(new GenericExprWrapper{common::Clone(*result)}); expr.typedExpr.reset(new GenericExprWrapper{common::Clone(*result)});
} else if (!fatalErrors_) {
CHECK(context_.AnyFatalError()); // somewhat expensive
fatalErrors_ = true;
} }
return result; return result;
} }
@ -1968,6 +1971,7 @@ evaluate::Expr<evaluate::SubscriptInteger> AnalyzeKindSelector(
auto save{analyzer.GetContextualMessages().SetLocation(*context.location())}; auto save{analyzer.GetContextualMessages().SetLocation(*context.location())};
return analyzer.AnalyzeKindSelector(category, selector); return analyzer.AnalyzeKindSelector(category, selector);
} }
bool ExprChecker::Walk(const parser::Program &program) { bool ExprChecker::Walk(const parser::Program &program) {
parser::Walk(program, *this); parser::Walk(program, *this);
return !context_.AnyFatalError(); return !context_.AnyFatalError();

View File

@ -249,6 +249,7 @@ private:
semantics::SemanticsContext &context_; semantics::SemanticsContext &context_;
std::map<parser::CharBlock, int> acImpliedDos_; // values are INTEGER kinds std::map<parser::CharBlock, int> acImpliedDos_; // values are INTEGER kinds
bool fatalErrors_{false};
}; };
template<typename L, typename R> template<typename L, typename R>
@ -303,6 +304,7 @@ public:
AnalyzeExpr(context_, x); AnalyzeExpr(context_, x);
return false; return false;
} }
template<typename A> bool Pre(const parser::Scalar<A> &x) { template<typename A> bool Pre(const parser::Scalar<A> &x) {
AnalyzeExpr(context_, x); AnalyzeExpr(context_, x);
return false; return false;