Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,26 @@ void OmpStructureChecker::CheckTargetUpdate() {
context_.Say(GetContext().directiveSource,
"At least one motion-clause (TO/FROM) must be specified on TARGET UPDATE construct."_err_en_US);
}
if (toClause && fromClause) {
SymbolSourceMap toSymbols, fromSymbols;
GetSymbolsInObjectList(
std::get<parser::OmpClause::To>(toClause->u).v, toSymbols);
GetSymbolsInObjectList(
std::get<parser::OmpClause::From>(fromClause->u).v, fromSymbols);
for (auto &[symbol, source] : toSymbols) {
auto fromSymbol = fromSymbols.find(symbol);
if (fromSymbol != fromSymbols.end()) {
context_.Say(source,
"A list item ('%s') can only appear in a TO or FROM clause, but not in both."_err_en_US,
symbol->name());
context_.Say(source, "'%s' appears in the TO clause."_because_en_US,
symbol->name());
context_.Say(fromSymbol->second,
"'%s' appears in the FROM clause."_because_en_US,
fromSymbol->first->name());
}
}
}
}

void OmpStructureChecker::Enter(
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Semantics/OpenMP/target-update01.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ subroutine foo(x)
!ERROR: At most one NOWAIT clause can appear on the TARGET UPDATE directive
!$omp target update to(x) nowait nowait

!ERROR: A list item ('x') can only appear in a TO or FROM clause, but not in both.
!BECAUSE: 'x' appears in the TO clause.
!BECAUSE: 'x' appears in the FROM clause.
!$omp target update to(x) from(x)

end subroutine