================
@@ -5080,6 +5080,55 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind 
DKind,
           Diag(Tok, diag::err_modifier_expected_colon) << "fallback";
       }
     }
+  } // Handle num_teams clause with optional lower-bound:upper-bound syntax
+  if (Kind == OMPC_num_teams && !Tok.is(tok::r_paren) &&
+      !Tok.is(tok::annot_pragma_openmp_end)) {
+    // Look ahead to detect top-level colon
+    TentativeParsingAction TPA(*this);
+    bool HasColon = false;
+    int Depth = 0;
+
+    while (!Tok.is(tok::annot_pragma_openmp_end)) {
+      if (Tok.is(tok::l_paren))
+        Depth++;
----------------
ykhatav wrote:

 I tried removing the depth tracking, but it causes test failures. 
ParseAssignmentExpression() stops at ":" even when delimiters are unbalanced 
(e.g.,num_teams((x+1:10) with missing )). Without depth tracking, this gets 
misparsed as colon syntax instead of reporting the delimiter mismatch error.
My intention of using depth tracking to distinguish valid colon syntax from 
malformed expressions.
Is there a better way to detect well-formed colon syntax that I'm missing?


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

Reply via email to