https://github.com/anondeveg updated 
https://github.com/llvm/llvm-project/pull/219638

>From d0fca1563282be18f5c4df66aed54a6b4a0ce0b6 Mon Sep 17 00:00:00 2001
From: Anondev <[email protected]>
Date: Sat, 29 Aug 2026 08:32:26 +0300
Subject: [PATCH 1/2] [clang][Parse] Improve diagnostics for '>>>' closing
 template parameter lists in CUDA.

---
 clang/lib/Parse/ParseTemplate.cpp                 | 11 ++++++++---
 clang/test/Parser/cuda-template-angle-brackets.cu |  3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Parser/cuda-template-angle-brackets.cu

diff --git a/clang/lib/Parse/ParseTemplate.cpp 
b/clang/lib/Parse/ParseTemplate.cpp
index 735a9bd1f9f1c..8d4dbf9db4a56 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -327,8 +327,8 @@ bool Parser::ParseTemplateParameters(
 
   // Try to parse the template parameter list.
   bool Failed = false;
-  // FIXME: Missing greatergreatergreater support.
-  if (!Tok.is(tok::greater) && !Tok.is(tok::greatergreater)) {
+  if (!Tok.is(tok::greater) && !Tok.is(tok::greatergreater) &&
+      !Tok.is(tok::greatergreatergreater)) {
     TemplateScopes.Enter(Scope::TemplateParamScope);
     Failed = ParseTemplateParameterList(Depth, TemplateParams);
   }
@@ -342,6 +342,10 @@ bool Parser::ParseTemplateParameters(
     Tok.setKind(tok::greater);
     RAngleLoc = Tok.getLocation();
     Tok.setLocation(Tok.getLocation().getLocWithOffset(1));
+  } else if (Tok.is(tok::greatergreatergreater)) {
+    Tok.setKind(tok::greatergreater);
+    RAngleLoc = Tok.getLocation();
+    Tok.setLocation(Tok.getLocation().getLocWithOffset(1));
   } else if (!TryConsumeToken(tok::greater, RAngleLoc) && Failed) {
     Diag(Tok.getLocation(), diag::err_expected) << tok::greater;
     return true;
@@ -367,7 +371,8 @@ Parser::ParseTemplateParameterList(const unsigned Depth,
     // Did we find a comma or the end of the template parameter list?
     if (Tok.is(tok::comma)) {
       ConsumeToken();
-    } else if (Tok.isOneOf(tok::greater, tok::greatergreater)) {
+    } else if (Tok.isOneOf(tok::greater, tok::greatergreater,
+                           tok::greatergreatergreater)) {
       // Don't consume this... that's done by template parser.
       break;
     } else {
diff --git a/clang/test/Parser/cuda-template-angle-brackets.cu 
b/clang/test/Parser/cuda-template-angle-brackets.cu
new file mode 100644
index 0000000000000..38d5a48e6b279
--- /dev/null
+++ b/clang/test/Parser/cuda-template-angle-brackets.cu
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <template <template <int>>> struct S; // expected-error 2 {{template 
template parameter requires 'class' or 'typename' after the parameter list}}

>From 31e4c39440e1049839c35f263b2d5351ce045a67 Mon Sep 17 00:00:00 2001
From: Anondev <[email protected]>
Date: Tue, 1 Sep 2026 05:58:02 +0300
Subject: [PATCH 2/2] [Clang] Add test for version control conflict markers

this exercises the CUDA tokenization where >>> is treated
as a single token, ensuring that the <<<< and >>>> sequences from
conflict markers are not incorrectly interpreted as C++/CUDA syntax.
---
 clang/test/Parser/cuda-version-control-conflict.cu | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 clang/test/Parser/cuda-version-control-conflict.cu

diff --git a/clang/test/Parser/cuda-version-control-conflict.cu 
b/clang/test/Parser/cuda-version-control-conflict.cu
new file mode 100644
index 0000000000000..5b2e56c771e6e
--- /dev/null
+++ b/clang/test/Parser/cuda-version-control-conflict.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// this exercises the CUDA tokenization where >>> is treated
+// as a single token, ensuring that the <<<< and >>>> sequences from
+// conflict markers are not incorrectly interpreted as C++/CUDA syntax. 
+
+// expected-error@+1 {{version control conflict marker in file}}
+<<<<<<< HEAD 
+int x = 5;
+=======
+int y = 0;
+>>>>>>> other-branch

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

Reply via email to