@@ -1543,46 +1543,28 @@ void OmpStructureChecker::CheckAtomicUpdateAssignmentStmt(
1543
1543
}
1544
1544
1545
1545
void OmpStructureChecker::CheckAtomicMemoryOrderClause (
1546
- const parser::OmpAtomicClauseList &clauseList) {
1546
+ const parser::OmpAtomicClauseList *leftHandClauseList,
1547
+ const parser::OmpAtomicClauseList *rightHandClauseList) {
1547
1548
int numMemoryOrderClause = 0 ;
1548
- for (const auto &clause : clauseList.v ) {
1549
- if (std::get_if<Fortran::parser::OmpMemoryOrderClause>(&clause.u )) {
1550
- numMemoryOrderClause++;
1551
- if (numMemoryOrderClause > 1 ) {
1552
- context_.Say (clause.source ,
1553
- " More than one memory order clause not allowed on OpenMP "
1554
- " Atomic construct" _err_en_US);
1555
- return ;
1556
- }
1557
- }
1558
- }
1559
- }
1560
-
1561
- void OmpStructureChecker::CheckAtomicMemoryOrderClause (
1562
- const parser::OmpAtomicClauseList &leftHandClauseList,
1563
- const parser::OmpAtomicClauseList &rightHandClauseList) {
1564
- int numMemoryOrderClause = 0 ;
1565
- for (const auto &clause : leftHandClauseList.v ) {
1566
- if (std::get_if<Fortran::parser::OmpMemoryOrderClause>(&clause.u )) {
1567
- numMemoryOrderClause++;
1568
- if (numMemoryOrderClause > 1 ) {
1569
- context_.Say (clause.source ,
1570
- " More than one memory order clause not allowed on "
1571
- " OpenMP Atomic construct" _err_en_US);
1572
- return ;
1573
- }
1574
- }
1549
+ auto checkForValidMemoryOrderClause =
1550
+ [&](const parser::OmpAtomicClauseList *clauseList) {
1551
+ for (const auto &clause : clauseList->v ) {
1552
+ if (std::get_if<Fortran::parser::OmpMemoryOrderClause>(&clause.u )) {
1553
+ numMemoryOrderClause++;
1554
+ if (numMemoryOrderClause > 1 ) {
1555
+ context_.Say (clause.source ,
1556
+ " More than one memory order clause not allowed on "
1557
+ " OpenMP Atomic construct" _err_en_US);
1558
+ return ;
1559
+ }
1560
+ }
1561
+ }
1562
+ };
1563
+ if (leftHandClauseList) {
1564
+ checkForValidMemoryOrderClause (leftHandClauseList);
1575
1565
}
1576
- for (const auto &clause : rightHandClauseList.v ) {
1577
- if (std::get_if<Fortran::parser::OmpMemoryOrderClause>(&clause.u )) {
1578
- numMemoryOrderClause++;
1579
- if (numMemoryOrderClause > 1 ) {
1580
- context_.Say (clause.source ,
1581
- " More than one memory order clause not "
1582
- " allowed on OpenMP Atomic construct" _err_en_US);
1583
- return ;
1584
- }
1585
- }
1566
+ if (rightHandClauseList) {
1567
+ checkForValidMemoryOrderClause (rightHandClauseList);
1586
1568
}
1587
1569
}
1588
1570
@@ -1598,25 +1580,26 @@ void OmpStructureChecker::Enter(const parser::OpenMPAtomicConstruct &x) {
1598
1580
atomicConstruct.t )
1599
1581
.statement );
1600
1582
CheckAtomicMemoryOrderClause (
1601
- std::get<parser::OmpAtomicClauseList>(atomicConstruct.t ));
1583
+ &std::get<parser::OmpAtomicClauseList>(atomicConstruct.t ),
1584
+ nullptr );
1602
1585
},
1603
- [&](const parser::OmpAtomicUpdate &atomicConstruct ) {
1604
- const auto &dir{std::get<parser::Verbatim>(atomicConstruct .t )};
1586
+ [&](const parser::OmpAtomicUpdate &atomicUpdate ) {
1587
+ const auto &dir{std::get<parser::Verbatim>(atomicUpdate .t )};
1605
1588
PushContextAndClauseSets (
1606
1589
dir.source , llvm::omp::Directive::OMPD_atomic);
1607
1590
CheckAtomicUpdateAssignmentStmt (
1608
1591
std::get<parser::Statement<parser::AssignmentStmt>>(
1609
- atomicConstruct .t )
1592
+ atomicUpdate .t )
1610
1593
.statement );
1611
1594
CheckAtomicMemoryOrderClause (
1612
- std::get<0 >(atomicConstruct .t ), std::get<2 >(atomicConstruct .t ));
1595
+ & std::get<0 >(atomicUpdate .t ), & std::get<2 >(atomicUpdate .t ));
1613
1596
},
1614
1597
[&](const auto &atomicConstruct) {
1615
1598
const auto &dir{std::get<parser::Verbatim>(atomicConstruct.t )};
1616
1599
PushContextAndClauseSets (
1617
1600
dir.source , llvm::omp::Directive::OMPD_atomic);
1618
- CheckAtomicMemoryOrderClause (
1619
- std::get< 0 >(atomicConstruct. t ), std::get<2 >(atomicConstruct.t ));
1601
+ CheckAtomicMemoryOrderClause (&std::get< 0 >(atomicConstruct. t ),
1602
+ & std::get<2 >(atomicConstruct.t ));
1620
1603
},
1621
1604
},
1622
1605
x.u );
0 commit comments