llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Serosh (Serosh-commits) <details> <summary>Changes</summary> Revert tentative action if 'operator' does not form a valid template-id. This ensures cached tokens match the scope range. fixes #<!-- -->186582. --- Full diff: https://github.com/llvm/llvm-project/pull/187370.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Parse/ParseExprCXX.cpp (+2-2) - (added) clang/test/Parser/gh186582.cpp (+13) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 613d87668be18..0f72c8e341e4c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -227,6 +227,7 @@ Bug Fixes in This Version - Fixed atomic boolean compound assignment; the conversion back to atomic bool would be miscompiled. (#GH33210) - Fixed a failed assertion in the preprocessor when ``__has_embed`` parameters are missing parentheses. (#GH175088) +- Fixed an assertion failure in the preprocessor when encountering ``::template operator`` during tentative parsing. (#GH186582) - Fix lifetime extension of temporaries in for-range-initializers in templates. (#GH165182) - Fixed a preprocessor crash in ``__has_cpp_attribute`` on incomplete scoped attributes. (#GH178098) 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..c3305813dd445 --- /dev/null +++ b/clang/test/Parser/gh186582.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void f() { + a( ::template operator +} // expected-error {{expected a type}} \ + // expected-error {{expected unqualified-id}} \ + // expected-error {{use of undeclared identifier 'a'}} \ + // expected-error {{expected ')'}} \ + // expected-note {{to match this '('}} \ + // expected-error {{expected ';' after expression}} + +// expected-error {{expected '}'}} \ +// expected-note {{to match this '{'}} `````````` </details> https://github.com/llvm/llvm-project/pull/187370 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
