From a90455057c3fca6d25fec113816b1550b6039304 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Fri, 12 Apr 2019 11:43:03 -0700 Subject: [PATCH] [flang] Ensure no failed expression analyses without fatal errors. Original-commit: flang-compiler/f18@3ef8b430311653cafb8f830c08ac08d5926bb11b Reviewed-on: https://github.com/flang-compiler/f18/pull/406 Tree-same-pre-rewrite: false --- flang/lib/semantics/expression.cc | 4 ++++ flang/lib/semantics/expression.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/flang/lib/semantics/expression.cc b/flang/lib/semantics/expression.cc index 144ea94..2f2db73 100644 --- a/flang/lib/semantics/expression.cc +++ b/flang/lib/semantics/expression.cc @@ -1832,6 +1832,9 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::Expr &expr) { } if (result.has_value()) { expr.typedExpr.reset(new GenericExprWrapper{common::Clone(*result)}); + } else if (!fatalErrors_) { + CHECK(context_.AnyFatalError()); // somewhat expensive + fatalErrors_ = true; } return result; } @@ -1968,6 +1971,7 @@ evaluate::Expr AnalyzeKindSelector( auto save{analyzer.GetContextualMessages().SetLocation(*context.location())}; return analyzer.AnalyzeKindSelector(category, selector); } + bool ExprChecker::Walk(const parser::Program &program) { parser::Walk(program, *this); return !context_.AnyFatalError(); diff --git a/flang/lib/semantics/expression.h b/flang/lib/semantics/expression.h index 73462926..fbeb2d9 100644 --- a/flang/lib/semantics/expression.h +++ b/flang/lib/semantics/expression.h @@ -249,6 +249,7 @@ private: semantics::SemanticsContext &context_; std::map acImpliedDos_; // values are INTEGER kinds + bool fatalErrors_{false}; }; template @@ -303,6 +304,7 @@ public: AnalyzeExpr(context_, x); return false; } + template bool Pre(const parser::Scalar &x) { AnalyzeExpr(context_, x); return false; -- 2.7.4