hintonda updated this revision to Diff 48561.
hintonda added a comment.

- Fix additional tests


http://reviews.llvm.org/D17407

Files:
  lib/Sema/SemaInit.cpp
  test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
  test/SemaCXX/cxx0x-initializer-aggregates.cpp
  test/SemaCXX/cxx0x-initializer-constructor.cpp
  test/SemaCXX/dcl_init_aggr.cpp
  test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
  test/SemaCXX/new-delete-cxx0x.cpp
  test/SemaCXX/pr23514-crash-on-invalid.cpp

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}}
Index: test/SemaCXX/new-delete-cxx0x.cpp
===================================================================
--- test/SemaCXX/new-delete-cxx0x.cpp
+++ test/SemaCXX/new-delete-cxx0x.cpp
@@ -15,8 +15,10 @@
   ~S();
 };
 
-struct T { // expected-note 2 {{not viable}}
-  T(int); // expected-note {{not viable}}
+struct T { // expected-note 2 {{not viable}} \
+           // expected-note {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}} \
+           // expected-note {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
+  T(int); // expected-note {{not viable}} expected-note {{candidate constructor not viable: requires 1 argument, but 0 were provided}}
 };
 
 void fn() {
@@ -29,5 +31,6 @@
   //
   // Note that this happens even if the array bound is constant and the
   // initializer initializes every array element.
-  (void) new T[2] {1, 2}; // expected-error {{no matching constructor}} expected-note {{in implicit initialization of array element 2}}
+  (void) new T[2] {1, 2}; // expected-error {{no matching constructor}} expected-note 2{{in implicit initialization of array element}} \
+                          // expected-error {{no matching constructor for initialization of 'T'}}
 }
Index: test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
===================================================================
--- test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
+++ test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
@@ -9,16 +9,17 @@
 template <class T>
 class vector {
 public:
-  explicit vector() {} // expected-warning 2 {{should not be explicit}}
+  explicit vector() {} // expected-warning 2 {{should not be explicit}} \
+                       // expected-warning 3{{invalid constructor form class in system header, should not be explicit}}
 };
 }
 }
 #else
 
 #define BE_THE_HEADER
 #include __FILE__
 
-struct { int a, b; std::__debug::vector<int> c; } e[] = { {1, 1} }; // expected-note{{used in initialization here}}
+struct { int a, b; std::__debug::vector<int> c; } e[] = { {1, 1} }; // expected-note 3{{used in initialization here}}
 // expected-warning@+1 {{expression with side effects has no effect in an unevaluated context}}
-decltype(new std::__debug::vector<int>[1]{}) x; // expected-note{{used in initialization here}}
+decltype(new std::__debug::vector<int>[1]{}) x; // expected-note 2{{used in initialization here}}
 #endif
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/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/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/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<rdar13395022::MoveOnly>' 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<MoveOnly> &&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: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -475,7 +475,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;
 }
 
@@ -6872,8 +6872,6 @@
 
   InitListChecker DiagnoseInitList(S, Entity, InitList, DestType,
                                    /*VerifyOnly=*/false);
-  assert(DiagnoseInitList.HadError() &&
-         "Inconsistent init list check result.");
 }
 
 bool InitializationSequence::Diagnose(Sema &S,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to