@@ -665,11 +665,6 @@ template <typename Checker> struct DirectiveSpellingVisitor {
665665 checker_ (x.v .DirName ().source , Directive::OMPD_groupprivate);
666666 return false ;
667667 }
668- bool Pre (const parser::OpenMPThreadprivate &x) {
669- checker_ (
670- std::get<parser::Verbatim>(x.t ).source , Directive::OMPD_threadprivate);
671- return false ;
672- }
673668 bool Pre (const parser::OpenMPRequiresConstruct &x) {
674669 checker_ (std::get<parser::Verbatim>(x.t ).source , Directive::OMPD_requires);
675670 return false ;
@@ -1294,15 +1289,20 @@ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar(
12941289 }
12951290}
12961291
1292+ void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar (
1293+ const parser::OmpObject &object) {
1294+ common::visit ( //
1295+ common::visitors{
1296+ [&](auto &&s) { CheckThreadprivateOrDeclareTargetVar (s); },
1297+ [&](const parser::OmpObject::Invalid &invalid) {},
1298+ },
1299+ object.u );
1300+ }
1301+
12971302void OmpStructureChecker::CheckThreadprivateOrDeclareTargetVar (
12981303 const parser::OmpObjectList &objList) {
12991304 for (const auto &ompObject : objList.v ) {
1300- common::visit ( //
1301- common::visitors{
1302- [&](auto &&s) { CheckThreadprivateOrDeclareTargetVar (s); },
1303- [&](const parser::OmpObject::Invalid &invalid) {},
1304- },
1305- ompObject.u );
1305+ CheckThreadprivateOrDeclareTargetVar (ompObject);
13061306 }
13071307}
13081308
@@ -1362,18 +1362,20 @@ void OmpStructureChecker::Leave(const parser::OpenMPGroupprivate &x) {
13621362 dirContext_.pop_back ();
13631363}
13641364
1365- void OmpStructureChecker::Enter (const parser::OpenMPThreadprivate &c) {
1366- const auto &dir{std::get<parser::Verbatim>(c.t )};
1367- PushContextAndClauseSets (
1368- dir.source , llvm::omp::Directive::OMPD_threadprivate);
1365+ void OmpStructureChecker::Enter (const parser::OpenMPThreadprivate &x) {
1366+ const parser::OmpDirectiveName &dirName{x.v .DirName ()};
1367+ PushContextAndClauseSets (dirName.source , dirName.v );
13691368}
13701369
1371- void OmpStructureChecker::Leave (const parser::OpenMPThreadprivate &c) {
1372- const auto &dir{std::get<parser::Verbatim>(c.t )};
1373- const auto &objectList{std::get<parser::OmpObjectList>(c.t )};
1374- CheckSymbolNames (dir.source , objectList);
1375- CheckVarIsNotPartOfAnotherVar (dir.source , objectList);
1376- CheckThreadprivateOrDeclareTargetVar (objectList);
1370+ void OmpStructureChecker::Leave (const parser::OpenMPThreadprivate &x) {
1371+ const parser::OmpDirectiveSpecification &dirSpec{x.v };
1372+ for (const parser::OmpArgument &arg : x.v .Arguments ().v ) {
1373+ if (auto *object{GetArgumentObject (arg)}) {
1374+ CheckSymbolName (dirSpec.source , *object);
1375+ CheckVarIsNotPartOfAnotherVar (dirSpec.source , *object);
1376+ CheckThreadprivateOrDeclareTargetVar (*object);
1377+ }
1378+ }
13771379 dirContext_.pop_back ();
13781380}
13791381
@@ -1672,30 +1674,35 @@ void OmpStructureChecker::Enter(const parser::OmpDeclareTargetWithList &x) {
16721674 }
16731675}
16741676
1675- void OmpStructureChecker::CheckSymbolNames (
1676- const parser::CharBlock &source, const parser::OmpObjectList &objList) {
1677- for (const auto &ompObject : objList.v ) {
1678- common::visit (
1679- common::visitors{
1680- [&](const parser::Designator &designator) {
1681- if (const auto *name{parser::Unwrap<parser::Name>(ompObject)}) {
1682- if (!name->symbol ) {
1683- context_.Say (source,
1684- " The given %s directive clause has an invalid argument" _err_en_US,
1685- ContextDirectiveAsFortran ());
1686- }
1687- }
1688- },
1689- [&](const parser::Name &name) {
1690- if (!name.symbol ) {
1677+ void OmpStructureChecker::CheckSymbolName (
1678+ const parser::CharBlock &source, const parser::OmpObject &object) {
1679+ common::visit (
1680+ common::visitors{
1681+ [&](const parser::Designator &designator) {
1682+ if (const auto *name{parser::Unwrap<parser::Name>(object)}) {
1683+ if (!name->symbol ) {
16911684 context_.Say (source,
16921685 " The given %s directive clause has an invalid argument" _err_en_US,
16931686 ContextDirectiveAsFortran ());
16941687 }
1695- },
1696- [&](const parser::OmpObject::Invalid &invalid) {},
1697- },
1698- ompObject.u );
1688+ }
1689+ },
1690+ [&](const parser::Name &name) {
1691+ if (!name.symbol ) {
1692+ context_.Say (source,
1693+ " The given %s directive clause has an invalid argument" _err_en_US,
1694+ ContextDirectiveAsFortran ());
1695+ }
1696+ },
1697+ [&](const parser::OmpObject::Invalid &invalid) {},
1698+ },
1699+ object.u );
1700+ }
1701+
1702+ void OmpStructureChecker::CheckSymbolNames (
1703+ const parser::CharBlock &source, const parser::OmpObjectList &objList) {
1704+ for (const auto &ompObject : objList.v ) {
1705+ CheckSymbolName (source, ompObject);
16991706 }
17001707}
17011708
0 commit comments