diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-07-14 22:58:04 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-07-14 22:58:04 +0000 |
commit | 699fc4d15c3fec9a7628632bb600be7c7d9e9e33 (patch) | |
tree | 65f3362cadafbd70be182e36a5de24f697039023 /clang/test | |
parent | 08903e4c167d1e8740c4df8f67f904e917fea8c2 (diff) | |
download | bcm5719-llvm-699fc4d15c3fec9a7628632bb600be7c7d9e9e33.tar.gz bcm5719-llvm-699fc4d15c3fec9a7628632bb600be7c7d9e9e33.zip |
Revert 135177 to fix PR10363.
Revert "For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either."
This reverts commit ac420c5053d6aa41d59f782caad9e46e5baaf2c2.
llvm-svn: 135210
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp | 63 | ||||
-rw-r--r-- | clang/test/SemaCXX/aggregate-initialization.cpp | 15 | ||||
-rw-r--r-- | clang/test/SemaCXX/generalized-initializers.cpp | 34 |
3 files changed, 71 insertions, 41 deletions
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp new file mode 100644 index 00000000000..9b92340fa45 --- /dev/null +++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp @@ -0,0 +1,63 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +// An aggregate is an array or a class... +struct Aggr { +private: + static const int n; + void f(); +protected: + struct Inner { int m; }; +public: + bool &br; +}; +bool b; +Aggr ag = { b }; + +// with no user-provided constructors, ... +struct NonAggr1a { + NonAggr1a(int, int); + int k; +}; +// In C++03, this is {{non-aggregate type 'NonAggr1a'}}. +// In C++0x, 'user-provided' is only defined for special member functions, so +// this type is considered to be an aggregate. This is probably a langauge +// defect. +NonAggr1a na1a = { 42 }; + +struct NonAggr1b { + NonAggr1b(const NonAggr1b &); + int k; +}; +NonAggr1b na1b = { 42 }; // expected-error {{non-aggregate type 'NonAggr1b'}} + +// no brace-or-equal-initializers for non-static data members, ... +struct NonAggr2 { + int m = { 123 }; +}; +NonAggr2 na2 = { 42 }; // expected-error {{non-aggregate type 'NonAggr2'}} + +// no private... +struct NonAggr3 { +private: + int n; +}; +NonAggr3 na3 = { 42 }; // expected-error {{non-aggregate type 'NonAggr3'}} + +// or protected non-static data members, ... +struct NonAggr4 { +protected: + int n; +}; +NonAggr4 na4 = { 42 }; // expected-error {{non-aggregate type 'NonAggr4'}} + +// no base classes, ... +struct NonAggr5 : Aggr { +}; +NonAggr5 na5 = { b }; // expected-error {{non-aggregate type 'NonAggr5'}} + +// and no virtual functions. +struct NonAggr6 { + virtual void f(); + int n; +}; +NonAggr6 na6 = { 42 }; // expected-error {{non-aggregate type 'NonAggr6'}} diff --git a/clang/test/SemaCXX/aggregate-initialization.cpp b/clang/test/SemaCXX/aggregate-initialization.cpp index d4896918982..b9e69b00b7f 100644 --- a/clang/test/SemaCXX/aggregate-initialization.cpp +++ b/clang/test/SemaCXX/aggregate-initialization.cpp @@ -1,7 +1,9 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s // Verify that we can't initialize non-aggregates with an initializer // list. +// FIXME: Note that due to a (likely) standard bug, this is technically an +// aggregate. struct NonAggr1 { NonAggr1(int) { } @@ -22,7 +24,7 @@ struct NonAggr4 { virtual void f(); }; -NonAggr1 na1 = { 17 }; // expected-error{{non-aggregate type 'NonAggr1' cannot be initialized with an initializer list}} +NonAggr1 na1 = { 17 }; NonAggr2 na2 = { 17 }; // expected-error{{non-aggregate type 'NonAggr2' cannot be initialized with an initializer list}} NonAggr3 na3 = { 17 }; // expected-error{{non-aggregate type 'NonAggr3' cannot be initialized with an initializer list}} NonAggr4 na4 = { 17 }; // expected-error{{non-aggregate type 'NonAggr4' cannot be initialized with an initializer list}} @@ -46,9 +48,8 @@ struct A { A(); A(int); ~A(); - -private: - A(const A&) {} // expected-note 4 {{declared private here}} + + A(const A&) = delete; // expected-note 2 {{function has been explicitly marked deleted here}} }; struct B { @@ -61,10 +62,10 @@ struct C { void f() { A as1[1] = { }; - A as2[1] = { 1 }; // expected-error {{calling a private constructor of class 'A'}} expected-warning {{requires an accessible copy constructor}} + A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted constructor}} B b1 = { }; - B b2 = { 1 }; // expected-error {{field of type 'A' has private copy constructor}} expected-warning {{requires an accessible copy constructor}} + B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted constructor}} C c1 = { 1 }; } diff --git a/clang/test/SemaCXX/generalized-initializers.cpp b/clang/test/SemaCXX/generalized-initializers.cpp index 738dc5cf2c7..6e2bee7e301 100644 --- a/clang/test/SemaCXX/generalized-initializers.cpp +++ b/clang/test/SemaCXX/generalized-initializers.cpp @@ -224,39 +224,5 @@ namespace aggregate { S s3{ 1, 2, 3, 4, 5, 6 }; // xpected-error S s4{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // xpected-error S s5{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // xpected-error - // May still omit stuff, though. - S s6{ {1}, {}, { {}, {} } }; } } - -namespace references { - // From [dcl.init.list]p3 bullet 5: - struct S { - S(std::initializer_list<double>); - S(const std::string&); - }; - void test() { - const S &r1 = { 1, 2, 3.0 }; // no-error (constructor #1) - const S &r2{ "Spinach" }; // no-error (constructor #2) - S &r3 = { 1, 2, 3 }; // xpected-error (binding to non-const) - const int &i1 = { 1 }; // no-error - const int &i2 = { 1.1 }; // xpected-error {{narrowing}} - const int (&iar)[2] = { 1, 2 }; // no-error - - // Edge case: the standard says this must create a temporary and thus - // fail to bind, but that's almost certainly a defect. - int i; - int &ri1{ i }; - int &ri2 = { i }; - S s{ "Spinach" }; - S &rs1{ s }; - S &rs2 = { s }; - } -} - -namespace incomplete { - // Just to make sure it doesn't crash. - struct S; - S s { 1, 2, 3 }; // expected-error {{incomplete}} - S t = { 1, 2, 3 }; // expected-error {{incomplete}} -} |