================
@@ -2689,6 +2722,88 @@ StmtResult 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(
     // A single match is returned for OpenMP 5.0
     int BestIdx = getBestVariantMatchForContext(VMIs, OMPCtx);
 
+    // Check if we have any user conditions.
+    bool HasUserCondition = false;
+    for (OMPTraitInfo *TI : TraitInfos) {
+      if (TI && TI->hasUserCondition()) {
+        HasUserCondition = true;
+        break;
+      }
+    }
+    // If we have user conditions, collect all variants.
+    if (HasUserCondition) {
+      // Collect all variants with their conditions.
+      SmallVector<OpenMPDirectiveKind, 4> DirectiveKinds;
+      SmallVector<Expr *, 4> Conditions;
+      SmallVector<OpenMPClauseKind, 4> ClauseKinds;
+      SmallVector<Stmt *, 4> VariantDirectives;
+
+      while (Tok.isNot(tok::annot_pragma_openmp_end)) {
+        OpenMPClauseKind CKind = Tok.isAnnotation()
+                                     ? OMPC_unknown
+                                     : 
getOpenMPClauseKind(PP.getSpelling(Tok));
+        SourceLocation ClauseLoc = ConsumeToken();
+
+        // Parse '('.
+        T.consumeOpen();
+
+        Expr *Condition = nullptr;
+        if (CKind == OMPC_when) {
+          OMPTraitInfo &TI = Actions.getASTContext().getNewOMPTraitInfo();
+          parseOMPContextSelectors(ClauseLoc, TI);
+
+          // Extract user condition if present.
+          TI.anyScoreOrCondition([&](Expr *&E, bool IsScore) {
+            if (!IsScore && E) {
+              Condition = E;
+              return true;
+            }
+            return false;
+          });
+          // Parse ':'.
+          if (Tok.is(tok::colon))
+            ConsumeAnyToken();
+        }
+
+        // Parse only the directive kind (not the full statement with body).
+        // The body will be shared across all variants and parsed after the
+        // metadirective.
+        OpenMPDirectiveKind DKind = OMPD_unknown;
+        Stmt *VariantDirective = nullptr;
+
+        if (!Tok.is(tok::r_paren)) {
+          DKind = parseOpenMPDirectiveKind(*this);
+          skipToMatchingParen();
----------------
alexey-bataev wrote:

All clauses are skipped and lost here

https://github.com/llvm/llvm-project/pull/192455
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to