Richard Smith | 54ca069 | 2013-07-04 00:13:48 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Daniel Dunbar | 9aa78d5 | 2009-09-12 23:06:30 +0000 | [diff] [blame] | 2 | |
Anders Carlsson | 8a1d229 | 2009-09-12 19:35:43 +0000 | [diff] [blame] | 3 | struct x { |
| 4 | x() : a(4) ; // expected-error {{expected '{'}} |
| 5 | }; |
| 6 | |
| 7 | struct y { |
| 8 | int a; |
| 9 | y() : a(4) ; // expected-error {{expected '{'}} |
| 10 | }; |
Sebastian Redl | a891a32 | 2011-09-30 08:32:17 +0000 | [diff] [blame] | 11 | |
| 12 | struct z { |
| 13 | int a; |
Richard Smith | 54ca069 | 2013-07-04 00:13:48 +0000 | [diff] [blame] | 14 | z() : a {} |
| 15 | }; // expected-error {{expected '{'}} |
| 16 | |
| 17 | namespace PR16480 { |
| 18 | template<int n> struct X { |
| 19 | X(); |
| 20 | X(int); |
| 21 | }; |
| 22 | |
| 23 | struct A : X<0> { |
| 24 | A() : X<a<b>{0}.n>() {} |
| 25 | |
| 26 | template<int> struct a { |
| 27 | int n; |
| 28 | }; |
| 29 | |
| 30 | static const int b = 1; |
| 31 | }; |
| 32 | |
| 33 | struct B : X<0> { |
| 34 | B() : X<a<b>{0} {} |
| 35 | |
| 36 | static const int a = 0, b = 0; |
| 37 | }; |
| 38 | |
| 39 | template<int> struct a { |
| 40 | constexpr a(int) {} |
| 41 | constexpr operator int() const { return 0; } |
| 42 | }; |
| 43 | |
| 44 | struct C : X<0> { |
| 45 | C() : X<a<b>(0)>() {} |
| 46 | |
| 47 | static const int b = 0; |
| 48 | }; |
| 49 | |
| 50 | struct D : X<0> { |
| 51 | D() : X<a<b>(0) {} |
| 52 | |
| 53 | static const int a = 0, b = 0; |
| 54 | }; |
| 55 | |
| 56 | template<typename T> struct E : X<0> { |
| 57 | E(X<0>) : X<(0)>{} {} |
| 58 | E(X<1>) : X<int{}>{} {} |
| 59 | E(X<2>) : X<(0)>() {} |
| 60 | E(X<3>) : X<int{}>() {} |
| 61 | }; |
| 62 | |
| 63 | // FIXME: This should be valid in the union of C99 and C++11. |
| 64 | struct F : X<0> { |
| 65 | F() : X<A<T>().n + (T){}.n>{} {} // expected-error +{{}} |
| 66 | |
| 67 | struct T { int n; }; |
| 68 | template<typename> struct A { int n; }; |
| 69 | }; // expected-error +{{}} |
| 70 | |
| 71 | // FIXME: This is valid now, but may be made ill-formed by DR1607. |
| 72 | struct G : X<0> { |
| 73 | G() : X<0 && [](){return 0;}()>{} // expected-error +{{}} |
| 74 | }; // expected-error +{{}} |
| 75 | |
| 76 | struct Errs : X<0> { |
| 77 | Errs(X<0>) : decltype X<0>() {} // expected-error {{expected '(' after 'decltype'}} |
| 78 | Errs(X<1>) : what is this () {} // expected-error {{expected '(' or '{'}} |
| 79 | Errs(X<2>) : decltype(X<0> // expected-note {{to match this '('}} |
| 80 | }; // expected-error {{expected ')'}} |
| 81 | } |