diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp --- a/flang/lib/Semantics/tools.cpp +++ b/flang/lib/Semantics/tools.cpp @@ -848,6 +848,9 @@ template bool operator()(const common::Indirection &x) { return (*this)(x.value()); } + template bool operator()(const parser::Statement &x) { + return (*this)(x.statement); + } bool operator()(const parser::AllocateStmt &stmt) { const auto &allocationList{std::get>(stmt.t)}; for (const auto &allocation : allocationList) { @@ -894,8 +897,13 @@ return std::get(stmt.t) == parser::StopStmt::Kind::Stop; } - bool operator()(const parser::Statement &stmt) { - return common::visit(*this, stmt.statement.u); + bool operator()(const parser::IfStmt &stmt) { + return (*this)( + std::get>(stmt.t) + .statement); + } + bool operator()(const parser::ActionStmt &stmt) { + return common::visit(*this, stmt.u); } private: diff --git a/flang/test/Semantics/doconcurrent01.f90 b/flang/test/Semantics/doconcurrent01.f90 --- a/flang/test/Semantics/doconcurrent01.f90 +++ b/flang/test/Semantics/doconcurrent01.f90 @@ -22,6 +22,11 @@ SYNC IMAGES (*) !ERROR: An image control statement is not allowed in DO CONCURRENT SYNC MEMORY +!ERROR: An image control statement is not allowed in DO CONCURRENT + stop +!ERROR: An image control statement is not allowed in DO CONCURRENT + if (.false.) stop + error stop ! ok !ERROR: RETURN is not allowed in DO CONCURRENT return 10 continue