@@ -5582,86 +5582,80 @@ void OmpStructureChecker::Enter(const parser::OpenMPInteropConstruct &x) {
5582
5582
bool isDependClauseOccured{false };
5583
5583
int targetCount{0 }, targetSyncCount{0 };
5584
5584
const auto &dir{std::get<parser::Verbatim>(x.t )};
5585
- std::list<std::string> ObjectNameList ;
5585
+ std::set< const Symbol *> objectSymbolList ;
5586
5586
PushContextAndClauseSets (dir.source , llvm::omp::Directive::OMPD_interop);
5587
5587
const auto &clauseList{std::get<parser::OmpClauseList>(x.t )};
5588
5588
for (const auto &clause : clauseList.v ) {
5589
5589
common::visit (
5590
5590
common::visitors{
5591
- [&](const parser::OmpClause::Init &InitClause ) {
5592
- if (OmpVerifyModifiers (InitClause .v , llvm::omp::OMPC_init,
5593
- GetContext ().directiveSource , context_)) {
5591
+ [&](const parser::OmpClause::Init &initClause ) {
5592
+ if (OmpVerifyModifiers (initClause .v , llvm::omp::OMPC_init,
5593
+ GetContext ().directiveSource , context_)) {
5594
5594
5595
- auto &modifiers{OmpGetModifiers (InitClause .v )};
5595
+ auto &modifiers{OmpGetModifiers (initClause .v )};
5596
5596
auto &&interopTypeModifier{
5597
5597
OmpGetRepeatableModifier<parser::OmpInteropType>(
5598
5598
modifiers)};
5599
- for (auto it{interopTypeModifier.begin ()},
5600
- end{interopTypeModifier.end ()};
5601
- it != end; ++it) {
5602
- if (parser::ToUpperCaseLetters (
5603
- parser::OmpInteropType::EnumToString ((*it)->v )) ==
5604
- " TARGETSYNC" ) {
5599
+ for (const auto &it : interopTypeModifier) {
5600
+ if (it->v == parser::OmpInteropType::Value::TargetSync) {
5605
5601
++targetSyncCount;
5606
5602
} else {
5607
5603
++targetCount;
5608
5604
}
5609
- if (targetCount > 1 || targetSyncCount > 1 ) {
5610
- context_.Say (GetContext ().directiveSource ,
5611
- " Each interop-type may be specified at most once." _err_en_US);
5612
- }
5613
5605
}
5614
5606
}
5615
- const auto &InteropVar{parser::Unwrap<parser::OmpObject>(
5616
- std::get<parser::OmpObject>(InitClause.v .t ))};
5617
- const auto *name{parser::Unwrap<parser::Name>(InteropVar)};
5618
- const auto ObjectName{name->ToString ()};
5619
- if (ObjectNameList.end () !=
5620
- std::find (ObjectNameList.begin (), ObjectNameList.end (),
5621
- ObjectName)) {
5622
- context_.Say (GetContext ().directiveSource ,
5607
+ const auto &interopVar{parser::Unwrap<parser::OmpObject>(
5608
+ std::get<parser::OmpObject>(initClause.v .t ))};
5609
+ const auto *name{parser::Unwrap<parser::Name>(interopVar)};
5610
+ const auto *objectSymbol{name->symbol };
5611
+ if (llvm::is_contained (objectSymbolList, objectSymbol)) {
5612
+ context_.Say (
5613
+ GetContext ().directiveSource ,
5623
5614
" Each interop-var may be specified for at most one action-clause of each interop construct." _err_en_US);
5624
5615
} else {
5625
- ObjectNameList. push_back (ObjectName );
5616
+ objectSymbolList. insert (objectSymbol );
5626
5617
}
5627
5618
},
5628
- [&](const parser::OmpClause::Depend &DependClause ) {
5619
+ [&](const parser::OmpClause::Depend &dependClause ) {
5629
5620
isDependClauseOccured = true ;
5630
5621
},
5631
- [&](const parser::OmpClause::Destroy &DestroyClause) {
5632
- const auto &InteropVar{
5633
- parser::Unwrap<parser::OmpObject>(DestroyClause.v )};
5634
- const auto *name{parser::Unwrap<parser::Name>(InteropVar)};
5635
- const auto ObjectName{name->ToString ()};
5636
- if (ObjectNameList.end () !=
5637
- std::find (ObjectNameList.begin (), ObjectNameList.end (),
5638
- ObjectName)) {
5639
- context_.Say (GetContext ().directiveSource ,
5622
+ [&](const parser::OmpClause::Destroy &destroyClause) {
5623
+ const auto &interopVar{
5624
+ parser::Unwrap<parser::OmpObject>(destroyClause.v )};
5625
+ const auto *name{parser::Unwrap<parser::Name>(interopVar)};
5626
+ const auto *objectSymbol{name->symbol };
5627
+ if (llvm::is_contained (objectSymbolList, objectSymbol)) {
5628
+ context_.Say (
5629
+ GetContext ().directiveSource ,
5640
5630
" Each interop-var may be specified for at most one action-clause of each interop construct." _err_en_US);
5641
5631
} else {
5642
- ObjectNameList. push_back (ObjectName );
5632
+ objectSymbolList. insert (objectSymbol );
5643
5633
}
5644
5634
},
5645
- [&](const parser::OmpClause::Use &UseClause) {
5646
- const auto &InteropVar{
5647
- parser::Unwrap<parser::OmpObject>(UseClause.v )};
5648
- const auto *name{parser::Unwrap<parser::Name>(InteropVar)};
5649
- const auto ObjectName{name->ToString ()};
5650
- if (ObjectNameList.end () !=
5651
- std::find (ObjectNameList.begin (), ObjectNameList.end (),
5652
- ObjectName)) {
5653
- context_.Say (GetContext ().directiveSource ,
5635
+ [&](const parser::OmpClause::Use &useClause) {
5636
+ const auto &interopVar{
5637
+ parser::Unwrap<parser::OmpObject>(useClause.v )};
5638
+ const auto *name{parser::Unwrap<parser::Name>(interopVar)};
5639
+ const auto *objectSymbol{name->symbol };
5640
+ if (llvm::is_contained (objectSymbolList, objectSymbol)) {
5641
+ context_.Say (
5642
+ GetContext ().directiveSource ,
5654
5643
" Each interop-var may be specified for at most one action-clause of each interop construct." _err_en_US);
5655
5644
} else {
5656
- ObjectNameList. push_back (ObjectName );
5645
+ objectSymbolList. insert (objectSymbol );
5657
5646
}
5658
5647
},
5659
5648
[&](const auto &) {},
5660
5649
},
5661
5650
clause.u );
5662
5651
}
5663
- if (isDependClauseOccured && ! targetSyncCount) {
5652
+ if (targetCount > 1 || targetSyncCount > 1 ) {
5664
5653
context_.Say (GetContext ().directiveSource ,
5654
+ " Each interop-type may be specified at most once." _err_en_US);
5655
+ }
5656
+ if (isDependClauseOccured && !targetSyncCount) {
5657
+ context_.Say (
5658
+ GetContext ().directiveSource ,
5665
5659
" A depend clause can only appear on the directive if the interop-type includes targetsync" _err_en_US);
5666
5660
}
5667
5661
}
0 commit comments