[clang] [clang]fix ppcaching assertion gh186582 (PR #187370)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 19 15:46:27 PDT 2026


https://github.com/Serosh-commits updated https://github.com/llvm/llvm-project/pull/187370

>From fc94d3d2928711d1ed47de8b6390b7eaa0ad1d36 Mon Sep 17 00:00:00 2001
From: Serosh-commits <janmejayapanda400 at gmail.com>
Date: Thu, 19 Mar 2026 00:57:24 +0530
Subject: [PATCH 1/2] test update

---
 clang/docs/ReleaseNotes.rst      | 2 ++
 clang/lib/Parse/ParseExprCXX.cpp | 4 ++--
 clang/test/Parser/gh186582.cpp   | 6 ++++++
 3 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Parser/gh186582.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 613d87668be18..a493fc8667d93 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -327,6 +327,8 @@ SystemZ Support
 - Add support for `#pragma export` for z/OS.  This is a pragma used to export functions and variables
   with external linkage from shared libraries.  It provides compatibility with the IBM XL C/C++
   compiler.
+- Fixed an assertion failure in the preprocessor when encountering ``::template operator`` during tentative parsing. (#GH186582)
+
 
 DWARF Support in Clang
 ----------------------
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 842b52375eb14..b50b5c383b961 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -286,7 +286,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
         // we already annotated the template-id.
         if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
                                        TemplateName)) {
-          TPA.Commit();
+          TPA.Revert();
           break;
         }
 
@@ -295,7 +295,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
           Diag(TemplateName.getSourceRange().getBegin(),
                diag::err_id_after_template_in_nested_name_spec)
             << TemplateName.getSourceRange();
-          TPA.Commit();
+          TPA.Revert();
           break;
         }
       } else {
diff --git a/clang/test/Parser/gh186582.cpp b/clang/test/Parser/gh186582.cpp
new file mode 100644
index 0000000000000..2c5d7cc0e1c6b
--- /dev/null
+++ b/clang/test/Parser/gh186582.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s
+
+a(   ::template operator // expected-error {{a type specifier is required for all declarations}} \
+                         // expected-error {{expected ';' after top level declarator}}
+// expected-error@* {{expected a type}}
+// expected-error@* {{expected unqualified-id}}

>From aab034b98df5c3ba2c7d579ac51e7a4ec604a136 Mon Sep 17 00:00:00 2001
From: Serosh-commits <janmejayapanda400 at gmail.com>
Date: Fri, 20 Mar 2026 03:33:32 +0530
Subject: [PATCH 2/2] ci fix

---
 clang/test/Parser/gh186582.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/test/Parser/gh186582.cpp b/clang/test/Parser/gh186582.cpp
index 2c5d7cc0e1c6b..597545fe7be55 100644
--- a/clang/test/Parser/gh186582.cpp
+++ b/clang/test/Parser/gh186582.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s
 
-a(   ::template operator // expected-error {{a type specifier is required for all declarations}} \
-                         // expected-error {{expected ';' after top level declarator}}
-// expected-error@* {{expected a type}}
-// expected-error@* {{expected unqualified-id}}
+a(   ::template operator; 
+// expected-error at 3 {{expected a type}}
+// expected-error at 3 {{a type specifier is required for all declarations}}
+// expected-error at 3 {{expected unqualified-id}}



More information about the cfe-commits mailing list