diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -455,6 +455,9 @@ - Fix crash when diagnosing default comparison method. (`#62791 `_) and (`#62102 `_). +- Fix crash when passing a braced initializer list to a parentehsized aggregate + initialization expression. + (`#63008 `_). Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -1158,6 +1158,7 @@ case InitializedEntity::EK_Parameter_CF_Audited: case InitializedEntity::EK_TemplateParameter: case InitializedEntity::EK_Result: + case InitializedEntity::EK_ParenAggInitMember: // Extra braces here are suspicious. DiagID = diag::warn_braces_around_init; break; @@ -1192,7 +1193,6 @@ case InitializedEntity::EK_LambdaToBlockConversionBlockElement: case InitializedEntity::EK_Binding: case InitializedEntity::EK_StmtExprResult: - case InitializedEntity::EK_ParenAggInitMember: llvm_unreachable("unexpected braced scalar init"); } diff --git a/clang/test/SemaCXX/paren-list-agg-init.cpp b/clang/test/SemaCXX/paren-list-agg-init.cpp --- a/clang/test/SemaCXX/paren-list-agg-init.cpp +++ b/clang/test/SemaCXX/paren-list-agg-init.cpp @@ -266,3 +266,9 @@ O o3(0); // expected-error@-1 {{reference member of type 'int &&' uninitialized}} } + +namespace gh63008 { +auto a = new A('a', {1.1}); +// expected-warning@-1 {{braces around scalar init}} +// beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}} +}