[flang-commits] [flang] [flang][OpenMP] Add semantic check for target update (PR #71305)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Sun Nov 5 07:04:03 PST 2023


================
@@ -1401,6 +1401,20 @@ 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) {
+      if (fromSymbols.find(symbol) != fromSymbols.end()) {
+        context_.Say(source,
+            "Symbol '%s': A list item can only appear in a to or from clause, but not in both."_err_en_US,
----------------
kiranchandramohan wrote:

Nit: We have the clause name in caps usually.
Symbol is an internal concept. Might be better to phrase in terms of what the standard says.
Would it be possible to highlight both occurrences?

https://github.com/llvm/llvm-project/pull/71305


More information about the flang-commits mailing list