From f85ac283c57eacb34d8673ab91a56c44f9e4115f Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Wed, 6 Mar 2019 14:15:13 -0800 Subject: [PATCH] [flang] Move ExprChecker into separate pass DoConcurrentChecker depends on expressions being fully resolved so it can't be in the same pass as ExprChecker. The same will probably apply to AssignmentChecker when its finished. Checks that don't depend on expressions can go in the first pass with ExprChecker. Original-commit: flang-compiler/f18@c0785ec06f58098d262cf2f791a98e74bdcef11b Reviewed-on: https://github.com/flang-compiler/f18/pull/315 --- flang/lib/semantics/semantics.cc | 13 +++++++++---- flang/lib/semantics/semantics.h | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/flang/lib/semantics/semantics.cc b/flang/lib/semantics/semantics.cc index d51823e..c48abef 100644 --- a/flang/lib/semantics/semantics.cc +++ b/flang/lib/semantics/semantics.cc @@ -48,10 +48,12 @@ template struct SemanticsVisitor : public virtual C... { return true; } template void Post(const N &node) { Leave(node); } + void Walk(const parser::Program &program) { parser::Walk(program, *this); } }; -using StatementSemantics = - SemanticsVisitor; +using StatementSemanticsPass1 = SemanticsVisitor; +using StatementSemanticsPass2 = + SemanticsVisitor; SemanticsContext::SemanticsContext( const common::IntrinsicTypeDefaultKinds &defaultKinds) @@ -102,8 +104,11 @@ bool Semantics::Perform() { if (AnyFatalError()) { return false; } - StatementSemantics visitor{context_}; - parser::Walk(program_, visitor); + StatementSemanticsPass1{context_}.Walk(program_); + if (AnyFatalError()) { + return false; + } + StatementSemanticsPass2{context_}.Walk(program_); if (AnyFatalError()) { return false; } diff --git a/flang/lib/semantics/semantics.h b/flang/lib/semantics/semantics.h index bf8df01..73c16a1 100644 --- a/flang/lib/semantics/semantics.h +++ b/flang/lib/semantics/semantics.h @@ -122,8 +122,8 @@ private: // Base class for semantics checkers. struct BaseChecker { - template void Enter(const C &x) {} - template void Leave(const C &x) {} + template void Enter(const N &) {} + template void Leave(const N &) {} }; } -- 2.7.4