Index: lib/Sema/SemaInit.cpp =================================================================== --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -474,7 +474,7 @@ SourceLocation Loc) { assert(VerifyOnly && "CheckEmptyInitializable is only inteded for verification mode."); - if (PerformEmptyInit(SemaRef, Loc, Entity, /*VerifyOnly*/true).isInvalid()) + if (PerformEmptyInit(SemaRef, Loc, Entity, /*VerifyOnly*/false).isInvalid()) hadError = true; } @@ -6871,8 +6871,6 @@ InitListChecker DiagnoseInitList(S, Entity, InitList, DestType, /*VerifyOnly=*/false); - assert(DiagnoseInitList.HadError() && - "Inconsistent init list check result."); } bool InitializationSequence::Diagnose(Sema &S, Index: test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp =================================================================== --- test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp +++ test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp @@ -112,16 +112,19 @@ } namespace rdar13395022 { - struct MoveOnly { // expected-note {{candidate}} - MoveOnly(MoveOnly&&); // expected-note 2{{copy constructor is implicitly deleted because}} expected-note {{candidate}} + struct MoveOnly { // expected-note 2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}} + MoveOnly(MoveOnly&&); // expected-note 2{{copy constructor is implicitly deleted because}} \ + // expected-note 2{{candidate constructor not viable: requires 1 argument, but 0 were provided}} }; void test(MoveOnly mo) { - auto &&list1 = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} expected-note {{in initialization of temporary of type 'std::initializer_list}} - MoveOnly (&&list2)[1] = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} expected-note {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]'}} + auto &&list1 = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} \ + // expected-note {{in initialization of temporary of type 'std::initializer_list' created to list-initialize this reference}} + MoveOnly (&&list2)[1] = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} \ + // expected-note {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]'}} std::initializer_list &&list3 = {}; - MoveOnly (&&list4)[1] = {}; // expected-error {{no matching constructor}} - // expected-note@-1 {{in implicit initialization of array element 0 with omitted initializer}} - // expected-note@-2 {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]' created to list-initialize this reference}} + MoveOnly (&&list4)[1] = {}; // expected-error 2{{no matching constructor for initialization of 'rdar13395022::MoveOnly'}} \ + // expected-note 2{{in implicit initialization of array element 0 with omitted initializer}} \ + // expected-note {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]' created to list-initialize this reference}} } } Index: test/SemaCXX/cxx0x-initializer-aggregates.cpp =================================================================== --- test/SemaCXX/cxx0x-initializer-aggregates.cpp +++ test/SemaCXX/cxx0x-initializer-aggregates.cpp @@ -40,8 +40,8 @@ (void) S{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; } - struct String { - String(const char*); + struct String { // expected-note 2{{candidate constructor (the implicit }} + String(const char*); // expected-note {{candidate constructor not viable: requires 1 argument, but 0 were provided}} }; struct A { @@ -56,7 +56,7 @@ struct B { int m1; - String m2; + String m2; // expected-note {{in implicit initialization of field 'm2' with omitted initializer}} }; void overloaded_call() { @@ -67,7 +67,7 @@ static_assert(sizeof(overloaded({1, "two"})) == sizeof(two), "bad overload"); // String is not default-constructible - static_assert(sizeof(overloaded({1})) == sizeof(one), "bad overload"); + static_assert(sizeof(overloaded({1})) == sizeof(one), "bad overload"); // expected-error {{no matching constructor for initialization of 'aggregate::String'}} } struct C { int a[2]; C():a({1, 2}) { } }; // expected-error {{parenthesized initialization of a member array is a GNU extension}} Index: test/SemaCXX/cxx0x-initializer-constructor.cpp =================================================================== --- test/SemaCXX/cxx0x-initializer-constructor.cpp +++ test/SemaCXX/cxx0x-initializer-constructor.cpp @@ -382,27 +382,31 @@ namespace PR11410 { struct A { - A() = delete; // expected-note 2{{deleted here}} + A() = delete; // expected-note 4{{'A' has been explicitly marked deleted here}} A(int); }; A a[3] = { {1}, {2} - }; // expected-error {{call to deleted constructor}} \ - expected-note {{in implicit initialization of array element 2 with omitted initializer}} + }; // expected-error {{call to deleted constructor}} expected-error {{call to deleted constructor of 'PR11410::A'}} \ + // expected-note {{in implicit initialization of array element 2 with omitted initializer}} \ + // expected-note {{in implicit initialization of array element 0 with omitted initializer}} + struct B { - A a; // expected-note {{in implicit initialization of field 'a'}} + A a; // expected-note 2{{in implicit initialization of field 'a'}} } b = { - }; // expected-error {{call to deleted constructor}} + }; // expected-error {{call to deleted constructor}} \ + // expected-error {{call to deleted constructor of 'PR11410::A'}} struct C { - C(int = 0); // expected-note 2{{candidate}} - C(float = 0); // expected-note 2{{candidate}} + C(int = 0); // expected-note 3{{candidate constructor}} + C(float = 0); // expected-note 3{{candidate constructor}} }; C c[3] = { 0, 1 - }; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 2}} + }; // expected-error {{ambiguous}} expected-note 2{{in implicit initialization of array element }} \ + // expected-error {{call to constructor of 'PR11410::C' is ambiguous}} C c2[3] = { [0] = 1, [2] = 3 }; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 1}} Index: test/SemaCXX/dcl_init_aggr.cpp =================================================================== --- test/SemaCXX/dcl_init_aggr.cpp +++ test/SemaCXX/dcl_init_aggr.cpp @@ -40,21 +40,24 @@ struct TooFew { int a; char* b; int c; }; TooFew too_few = { 1, "asdf" }; // expected-warning{{conversion from string literal to 'char *' is deprecated}} -struct NoDefaultConstructor { // expected-note 3 {{candidate constructor (the implicit copy constructor)}} \ +struct NoDefaultConstructor { // expected-note 6 {{candidate constructor (the implicit copy constructor)}} \ // expected-note{{declared here}} - NoDefaultConstructor(int); // expected-note 3 {{candidate constructor}} + NoDefaultConstructor(int); // expected-note 6 {{candidate constructor}} }; -struct TooFewError { // expected-error{{implicit default constructor for}} +struct TooFewError { // expected-error{{implicit default constructor for}} \ + // expected-note {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}} int a; - NoDefaultConstructor nodef; // expected-note{{member is declared here}} expected-note 2{{in implicit initialization of field 'nodef'}} + NoDefaultConstructor nodef; // expected-note{{member is declared here}} expected-note 4{{in implicit initialization of field 'nodef'}} }; TooFewError too_few_okay = { 1, 1 }; -TooFewError too_few_error = { 1 }; // expected-error{{no matching constructor}} +TooFewError too_few_error = { 1 }; // expected-error 2{{no matching constructor}} -TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}} -TooFewError too_few_error2[2] = { 1 }; // expected-error{{no matching constructor}} +TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}} \ + // expected-error {{no matching constructor}} \ + // expected-note {{in implicit initialization of array element 1 with omitted initializer}} +TooFewError too_few_error2[2] = { 1 }; // expected-error 2{{no matching constructor}} -NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}} expected-note {{implicit initialization of array element 0}} +NoDefaultConstructor too_few_error3[3] = { }; // expected-error 2{{no matching constructor}} expected-note 2 {{implicit initialization of array element 0}} // C++ [dcl.init.aggr]p8 struct Empty { }; @@ -76,11 +79,13 @@ // C++ [dcl.init.aggr]p9 struct HasReference { int i; - int &j; // expected-note{{uninitialized reference member is here}} + int &j; // expected-note{{uninitialized reference member is here}} \ + // expected-note {{in implicit initialization of field 'j' with omitted initializer}} }; int global_int; HasReference r1 = { 1, global_int }; -HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}} +HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}} \ + // expected-error {{reference to type 'int' requires an initializer}} // C++ [dcl.init.aggr]p10 // Note: the behavior here is identical to C Index: test/SemaCXX/pr23514-crash-on-invalid.cpp =================================================================== --- /dev/null +++ test/SemaCXX/pr23514-crash-on-invalid.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// Don't crash (PR13394). + +struct Test { + int& a; + int& b; // expected-note {{in implicit initialization of field 'b' with omitted initializer}} +}; + +int d = 0; +auto a = Test { + .b = d, + .a = d, +}; // expected-error {{reference to type 'int' requires an initializer}}