diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -311,6 +311,11 @@ `Issue 58067 `_ `Issue 59014 `_ `Issue 54746 `_ +- Fix assert that triggers a crash during some types of list initialization that + generate a CXXTemporaryObjectExpr instead of a InitListExpr. This fixes + `Issue 58302 `_ + `Issue 58753 `_ + `Issue 59100 `_ Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1459,9 +1459,8 @@ QualType Ty = TInfo->getType(); SourceLocation TyBeginLoc = TInfo->getTypeLoc().getBeginLoc(); - assert((!ListInitialization || - (Exprs.size() == 1 && isa(Exprs[0]))) && - "List initialization must have initializer list as expression."); + assert((!ListInitialization || Exprs.size() == 1) && + "List initialization must have exactly one expression."); SourceRange FullRange = SourceRange(TyBeginLoc, RParenOrBraceLoc); InitializedEntity Entity = diff --git a/clang/test/SemaCXX/cxx0x-initializer-references.cpp b/clang/test/SemaCXX/cxx0x-initializer-references.cpp --- a/clang/test/SemaCXX/cxx0x-initializer-references.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-references.cpp @@ -140,3 +140,21 @@ namespace PR21834 { const int &a = (const int &){0}; // expected-error {{cannot bind to an initializer list}} } + +namespace GH59100 { +class v {}; + +template +class V : public v {}; + +using T = const V &; + +template +void f() { + auto t = T{}; +} + +void z() { + f(); +} +} diff --git a/clang/test/SemaCXX/cxx2a-consteval.cpp b/clang/test/SemaCXX/cxx2a-consteval.cpp --- a/clang/test/SemaCXX/cxx2a-consteval.cpp +++ b/clang/test/SemaCXX/cxx2a-consteval.cpp @@ -1018,3 +1018,14 @@ (void)[](int i) consteval { return i; }(0); } } // namespace GH50455 + +namespace GH58302 { +struct A { + consteval A(){} + consteval operator int() { return 1;} +}; + +int f() { + int x = A{}; +} +}