Author: cor3ntin Date: 2024-07-12T13:12:14+02:00 New Revision: 84bc0a9e02bbcfc0f1e1333f642be37e687fb429
URL: https://github.com/llvm/llvm-project/commit/84bc0a9e02bbcfc0f1e1333f642be37e687fb429 DIFF: https://github.com/llvm/llvm-project/commit/84bc0a9e02bbcfc0f1e1333f642be37e687fb429.diff LOG: [Clang] Fix parsing of invalid type-requirement (#98545) A type-requirement cannot be an operator-function-id Fixes #51868 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplate.cpp clang/test/Parser/cxx-concepts-requires-clause.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 781fc8ab1de1e..2bca35cd4cf3c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1035,6 +1035,7 @@ Bug Fixes to C++ Support - Fixed a CTAD substitution bug involving type aliases that reference outer template parameters. (#GH94614). - Clang now correctly handles unexpanded packs in the template parameter list of a generic lambda expression (#GH48937) +- Fix a crash when parsing an invalid type-requirement in a requires expression. (#GH51868) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index dfc861195d0a9..bb36736c021b3 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -11690,6 +11690,13 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, // Construct a dependent template specialization type. assert(DTN && "dependent template has non-dependent name?"); assert(DTN->getQualifier() == SS.getScopeRep()); + + if (!DTN->isIdentifier()) { + Diag(TemplateIILoc, diag::err_template_id_not_a_type) << Template; + NoteAllFoundTemplates(Template); + return true; + } + QualType T = Context.getDependentTemplateSpecializationType( ElaboratedTypeKeyword::Typename, DTN->getQualifier(), DTN->getIdentifier(), TemplateArgs.arguments()); diff --git a/clang/test/Parser/cxx-concepts-requires-clause.cpp b/clang/test/Parser/cxx-concepts-requires-clause.cpp index 5b5bc9ea978bf..13b4e8439882d 100644 --- a/clang/test/Parser/cxx-concepts-requires-clause.cpp +++ b/clang/test/Parser/cxx-concepts-requires-clause.cpp @@ -195,3 +195,12 @@ void F() { int a = []<int=0> requires requires { [](auto){}; } { return 0; }(); } // namespace GH78524 + + +namespace GH51868 { +template<auto L> +concept C = requires { + typename decltype(L)::template operator()<int>; + // expected-error@-1 {{template name refers to non-type template 'decltype(L)::template operator ()'}} +}; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits