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 <[email protected]> Date: Thu, 19 Mar 2026 00:57:24 +0530 Subject: [PATCH 1/4] 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 f48ac79ef45ef4aec891288780f634fe1b4d6722 Mon Sep 17 00:00:00 2001 From: Serosh-commits <[email protected]> Date: Fri, 20 Mar 2026 03:33:32 +0530 Subject: [PATCH 2/4] ci fix --- clang/test/Parser/gh186582.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/clang/test/Parser/gh186582.cpp b/clang/test/Parser/gh186582.cpp index 2c5d7cc0e1c6b..b14f635546650 100644 --- a/clang/test/Parser/gh186582.cpp +++ b/clang/test/Parser/gh186582.cpp @@ -1,6 +1,7 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s - -a( ::template operator // expected-error {{a type specifier is required for all declarations}} \ +// RUN: %clang_cc1 -fsyntax-only -verify %s +a( ::template operator // expected-error 2 {{expected a type}} \ + // 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 be70f79e8947a112e5e1aafdf7eaa7eb7381c8d6 Mon Sep 17 00:00:00 2001 From: Serosh-commits <[email protected]> Date: Fri, 3 Apr 2026 16:37:33 +0530 Subject: [PATCH 3/4] [Clang][Parser] Fix crash in AnnotatePreviousCachedTokens when parsing ::template operator --- clang/test/Parser/gh186582.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/clang/test/Parser/gh186582.cpp b/clang/test/Parser/gh186582.cpp index b14f635546650..fb6e6c1383192 100644 --- a/clang/test/Parser/gh186582.cpp +++ b/clang/test/Parser/gh186582.cpp @@ -1,7 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -a( ::template operator // expected-error 2 {{expected a type}} \ - // expected-error {{a type specifier is required for all declarations}} \ - // expected-error {{expected ';' after top level declarator}} - - +// RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s +a( ::template operator; +// expected-error@3 {{expected a type}} +// expected-error@3 {{a type specifier is required for all declarations}} +// expected-error@3 {{expected unqualified-id}} \ No newline at end of file >From 1fea754195742f4e5632371695f408a8e61192e9 Mon Sep 17 00:00:00 2001 From: Serosh-commits <[email protected]> Date: Thu, 9 Apr 2026 22:53:07 +0530 Subject: [PATCH 4/4] fix assertion crash and refine recovery in ParseOptionalCXXScopeSpecifier --- clang/lib/Parse/ParseExprCXX.cpp | 6 ++++-- clang/test/Parser/gh186582.cpp | 5 +---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index b50b5c383b961..3f9a4e855d242 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -287,7 +287,8 @@ bool Parser::ParseOptionalCXXScopeSpecifier( if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType, TemplateName)) { TPA.Revert(); - break; + ConsumeToken(); + return true; } if (TemplateName.getKind() != UnqualifiedIdKind::IK_OperatorFunctionId && @@ -296,7 +297,8 @@ bool Parser::ParseOptionalCXXScopeSpecifier( diag::err_id_after_template_in_nested_name_spec) << TemplateName.getSourceRange(); TPA.Revert(); - break; + ConsumeToken(); + return true; } } else { TPA.Revert(); diff --git a/clang/test/Parser/gh186582.cpp b/clang/test/Parser/gh186582.cpp index fb6e6c1383192..e0d6a7031b662 100644 --- a/clang/test/Parser/gh186582.cpp +++ b/clang/test/Parser/gh186582.cpp @@ -1,6 +1,3 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++23 -verify %s -a( ::template operator; -// expected-error@3 {{expected a type}} -// expected-error@3 {{a type specifier is required for all declarations}} -// expected-error@3 {{expected unqualified-id}} \ No newline at end of file +a( ::template operator // expected-error {{expected a type}} expected-error {{unknown type name 'a'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected unqualified-id}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
