File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1401,6 +1401,26 @@ void OmpStructureChecker::CheckTargetUpdate() {
14011401 context_.Say (GetContext ().directiveSource ,
14021402 " At least one motion-clause (TO/FROM) must be specified on TARGET UPDATE construct." _err_en_US);
14031403 }
1404+ if (toClause && fromClause) {
1405+ SymbolSourceMap toSymbols, fromSymbols;
1406+ GetSymbolsInObjectList (
1407+ std::get<parser::OmpClause::To>(toClause->u ).v , toSymbols);
1408+ GetSymbolsInObjectList (
1409+ std::get<parser::OmpClause::From>(fromClause->u ).v , fromSymbols);
1410+ for (auto &[symbol, source] : toSymbols) {
1411+ auto fromSymbol = fromSymbols.find (symbol);
1412+ if (fromSymbol != fromSymbols.end ()) {
1413+ context_.Say (source,
1414+ " A list item ('%s') can only appear in a TO or FROM clause, but not in both." _err_en_US,
1415+ symbol->name ());
1416+ context_.Say (source, " '%s' appears in the TO clause." _because_en_US,
1417+ symbol->name ());
1418+ context_.Say (fromSymbol->second ,
1419+ " '%s' appears in the FROM clause." _because_en_US,
1420+ fromSymbol->first ->name ());
1421+ }
1422+ }
1423+ }
14041424}
14051425
14061426void OmpStructureChecker::Enter (
Original file line number Diff line number Diff line change @@ -13,4 +13,9 @@ subroutine foo(x)
1313 ! ERROR: At most one NOWAIT clause can appear on the TARGET UPDATE directive
1414 ! $omp target update to(x) nowait nowait
1515
16+ ! ERROR: A list item ('x') can only appear in a TO or FROM clause, but not in both.
17+ ! BECAUSE: 'x' appears in the TO clause.
18+ ! BECAUSE: 'x' appears in the FROM clause.
19+ ! $omp target update to(x) from(x)
20+
1621end subroutine
You can’t perform that action at this time.
0 commit comments