@@ -269,7 +269,8 @@ bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
269269}
270270
271271void OmpStructureChecker::AnalyzeObject (const parser::OmpObject &object) {
272- if (std::holds_alternative<parser::Name>(object.u )) {
272+ if (std::holds_alternative<parser::Name>(object.u ) ||
273+ std::holds_alternative<parser::OmpObject::Invalid>(object.u )) {
273274 // Do not analyze common block names. The analyzer will flag an error
274275 // on those.
275276 return ;
@@ -294,7 +295,12 @@ void OmpStructureChecker::AnalyzeObject(const parser::OmpObject &object) {
294295 }
295296 evaluate::ExpressionAnalyzer ea{context_};
296297 auto restore{ea.AllowWholeAssumedSizeArray (true )};
297- common::visit ([&](auto &&s) { ea.Analyze (s); }, object.u );
298+ common::visit ( //
299+ common::visitors{
300+ [&](auto &&s) { ea.Analyze (s); },
301+ [&](const parser::OmpObject::Invalid &invalid) {},
302+ },
303+ object.u );
298304}
299305
300306void OmpStructureChecker::AnalyzeObjects (const parser::OmpObjectList &objects) {
@@ -538,6 +544,7 @@ void OmpStructureChecker::CheckPredefinedAllocatorRestriction(
538544 [&](const parser::Name &name) {
539545 CheckPredefinedAllocatorRestriction (source, name);
540546 },
547+ [&](const parser::OmpObject::Invalid &invalid) {},
541548 },
542549 ompObject.u );
543550 }
@@ -1290,7 +1297,11 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
12901297void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar (
12911298 const parser::OmpObjectList &objList) {
12921299 for (const auto &ompObject : objList.v ) {
1293- common::visit ([&](auto &&s) { CheckThreadprivateOrDeclareTargetVar (s); },
1300+ common::visit ( //
1301+ common::visitors{
1302+ [&](auto &&s) { CheckThreadprivateOrDeclareTargetVar (s); },
1303+ [&](const parser::OmpObject::Invalid &invalid) {},
1304+ },
12941305 ompObject.u );
12951306 }
12961307}
@@ -1422,8 +1433,14 @@ void OmpStructureChecker::Enter(const parser::OpenMPDepobjConstruct &x) {
14221433 // refer to the same depend object as the depobj argument of the construct.
14231434 if (clause.Id () == llvm::omp::Clause::OMPC_destroy) {
14241435 auto getObjSymbol{[&](const parser::OmpObject &obj) {
1425- return common::visit (
1426- [&](auto &&s) { return GetLastName (s).symbol ; }, obj.u );
1436+ return common::visit ( //
1437+ common::visitors{
1438+ [&](auto &&s) { return GetLastName (s).symbol ; },
1439+ [&](const parser::OmpObject::Invalid &invalid) {
1440+ return static_cast <Symbol *>(nullptr );
1441+ },
1442+ },
1443+ obj.u );
14271444 }};
14281445 auto getArgSymbol{[&](const parser::OmpArgument &arg) {
14291446 if (auto *locator{std::get_if<parser::OmpLocator>(&arg.u )}) {
@@ -1438,9 +1455,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPDepobjConstruct &x) {
14381455 if (const std::optional<parser::OmpDestroyClause> &destroy{wrapper.v }) {
14391456 const Symbol *constrSym{getArgSymbol (arguments.v .front ())};
14401457 const Symbol *clauseSym{getObjSymbol (destroy->v )};
1441- assert (constrSym && " Unresolved depobj construct symbol" );
1442- assert (clauseSym && " Unresolved destroy symbol on depobj construct" );
1443- if (constrSym != clauseSym) {
1458+ if (constrSym && clauseSym && constrSym != clauseSym) {
14441459 context_.Say (x.source ,
14451460 " The DESTROY clause must refer to the same object as the "
14461461 " DEPOBJ construct" _err_en_US);
@@ -1678,6 +1693,7 @@ void OmpStructureChecker::CheckSymbolNames(
16781693 ContextDirectiveAsFortran ());
16791694 }
16801695 },
1696+ [&](const parser::OmpObject::Invalid &invalid) {},
16811697 },
16821698 ompObject.u );
16831699 }
@@ -2698,6 +2714,7 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
26982714 }
26992715 }
27002716 },
2717+ [&](const parser::OmpObject::Invalid &invalid) {},
27012718 },
27022719 ompObject.u );
27032720 }
@@ -3405,6 +3422,7 @@ void OmpStructureChecker::CheckVarIsNotPartOfAnotherVar(
34053422 }
34063423 },
34073424 [&](const parser::Name &name) {},
3425+ [&](const parser::OmpObject::Invalid &invalid) {},
34083426 },
34093427 ompObject.u );
34103428}
@@ -4090,11 +4108,11 @@ void OmpStructureChecker::CheckStructureComponent(
40904108 }};
40914109
40924110 for (const auto &object : objects.v ) {
4093- common::visit (
4094- common::visitors{
4095- CheckComponent ,
4096- [&](const parser::Name &name ) {},
4097- },
4111+ common::visit (common::visitors{
4112+ CheckComponent,
4113+ [&]( const parser::Name &name) {} ,
4114+ [&](const parser::OmpObject::Invalid &invalid ) {},
4115+ },
40984116 object.u );
40994117 }
41004118}
0 commit comments