1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc struct x { 4f4a2713aSLionel Sambuc x() : a(4) ; // expected-error {{expected '{'}} 5f4a2713aSLionel Sambuc }; 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc struct y { 8f4a2713aSLionel Sambuc int a; 9f4a2713aSLionel Sambuc y() : a(4) ; // expected-error {{expected '{'}} 10f4a2713aSLionel Sambuc }; 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuc struct z { 13f4a2713aSLionel Sambuc int a; 14f4a2713aSLionel Sambuc z() : a {} 15f4a2713aSLionel Sambuc }; // expected-error {{expected '{'}} 16f4a2713aSLionel Sambuc 17f4a2713aSLionel Sambuc namespace PR16480 { 18f4a2713aSLionel Sambuc template<int n> struct X { 19f4a2713aSLionel Sambuc X(); 20f4a2713aSLionel Sambuc X(int); 21f4a2713aSLionel Sambuc }; 22f4a2713aSLionel Sambuc 23f4a2713aSLionel Sambuc struct A : X<0> { APR16480::A24f4a2713aSLionel Sambuc A() : X<a<b>{0}.n>() {} 25f4a2713aSLionel Sambuc 26f4a2713aSLionel Sambuc template<int> struct a { 27f4a2713aSLionel Sambuc int n; 28f4a2713aSLionel Sambuc }; 29f4a2713aSLionel Sambuc 30f4a2713aSLionel Sambuc static const int b = 1; 31f4a2713aSLionel Sambuc }; 32f4a2713aSLionel Sambuc 33f4a2713aSLionel Sambuc struct B : X<0> { BPR16480::B34f4a2713aSLionel Sambuc B() : X<a<b>{0} {} 35f4a2713aSLionel Sambuc 36f4a2713aSLionel Sambuc static const int a = 0, b = 0; 37f4a2713aSLionel Sambuc }; 38f4a2713aSLionel Sambuc 39f4a2713aSLionel Sambuc template<int> struct a { aPR16480::a40f4a2713aSLionel Sambuc constexpr a(int) {} operator intPR16480::a41f4a2713aSLionel Sambuc constexpr operator int() const { return 0; } 42f4a2713aSLionel Sambuc }; 43f4a2713aSLionel Sambuc 44f4a2713aSLionel Sambuc struct C : X<0> { CPR16480::C45f4a2713aSLionel Sambuc C() : X<a<b>(0)>() {} 46f4a2713aSLionel Sambuc 47f4a2713aSLionel Sambuc static const int b = 0; 48f4a2713aSLionel Sambuc }; 49f4a2713aSLionel Sambuc 50f4a2713aSLionel Sambuc struct D : X<0> { DPR16480::D51f4a2713aSLionel Sambuc D() : X<a<b>(0) {} 52f4a2713aSLionel Sambuc 53f4a2713aSLionel Sambuc static const int a = 0, b = 0; 54f4a2713aSLionel Sambuc }; 55f4a2713aSLionel Sambuc 56f4a2713aSLionel Sambuc template<typename T> struct E : X<0> { EPR16480::E57f4a2713aSLionel Sambuc E(X<0>) : X<(0)>{} {} EPR16480::E58f4a2713aSLionel Sambuc E(X<1>) : X<int{}>{} {} EPR16480::E59f4a2713aSLionel Sambuc E(X<2>) : X<(0)>() {} EPR16480::E60f4a2713aSLionel Sambuc E(X<3>) : X<int{}>() {} 61f4a2713aSLionel Sambuc }; 62f4a2713aSLionel Sambuc 63f4a2713aSLionel Sambuc // FIXME: This should be valid in the union of C99 and C++11. 64f4a2713aSLionel Sambuc struct F : X<0> { FPR16480::F65f4a2713aSLionel Sambuc F() : X<A<T>().n + (T){}.n>{} {} // expected-error +{{}} 66f4a2713aSLionel Sambuc 67f4a2713aSLionel Sambuc struct T { int n; }; 68f4a2713aSLionel Sambuc template<typename> struct A { int n; }; 69*0a6a1f1dSLionel Sambuc }; 70f4a2713aSLionel Sambuc 71f4a2713aSLionel Sambuc // FIXME: This is valid now, but may be made ill-formed by DR1607. 72f4a2713aSLionel Sambuc struct G : X<0> { __anon01a6f28e0402PR16480::G73f4a2713aSLionel Sambuc G() : X<0 && [](){return 0;}()>{} // expected-error +{{}} 74*0a6a1f1dSLionel Sambuc }; 75f4a2713aSLionel Sambuc 76f4a2713aSLionel Sambuc struct Errs : X<0> { ErrsPR16480::Errs77f4a2713aSLionel Sambuc Errs(X<0>) : decltype X<0>() {} // expected-error {{expected '(' after 'decltype'}} ErrsPR16480::Errs78f4a2713aSLionel Sambuc Errs(X<1>) : what is this () {} // expected-error {{expected '(' or '{'}} 79f4a2713aSLionel Sambuc Errs(X<2>) : decltype(X<0> // expected-note {{to match this '('}} 80f4a2713aSLionel Sambuc }; // expected-error {{expected ')'}} 81f4a2713aSLionel Sambuc } 82*0a6a1f1dSLionel Sambuc 83*0a6a1f1dSLionel Sambuc template <class U, class V> struct C { 84*0a6a1f1dSLionel Sambuc int f() { return 4; } 85*0a6a1f1dSLionel Sambuc class C1 {}; 86*0a6a1f1dSLionel Sambuc }; 87*0a6a1f1dSLionel Sambuc 88*0a6a1f1dSLionel Sambuc class D {}; 89*0a6a1f1dSLionel Sambuc namespace N { 90*0a6a1f1dSLionel Sambuc struct E { 91*0a6a1f1dSLionel Sambuc class F {}; 92*0a6a1f1dSLionel Sambuc }; 93*0a6a1f1dSLionel Sambuc } 94*0a6a1f1dSLionel Sambuc 95*0a6a1f1dSLionel Sambuc class G { 96*0a6a1f1dSLionel Sambuc // These are all valid: 97*0a6a1f1dSLionel Sambuc void f(int x = C<int, D>().f()) {} 98*0a6a1f1dSLionel Sambuc void g(int x = C<int, ::D>().f()) {} 99*0a6a1f1dSLionel Sambuc void h(int x = C<int, N::E>().f()) {} 100*0a6a1f1dSLionel Sambuc void i(int x = C<int, ::N::E>().f()) {} 101*0a6a1f1dSLionel Sambuc void j(int x = C<int, decltype(N::E())::F>().f()) {} 102*0a6a1f1dSLionel Sambuc void k(int x = C<int, C<int, int>>().f()) {} 103*0a6a1f1dSLionel Sambuc void l(int x = C<int, C<int, int>::C1>().f()) {} 104*0a6a1f1dSLionel Sambuc 105*0a6a1f1dSLionel Sambuc // This isn't, but it shouldn't crash. The diagnostics don't matter much. 106*0a6a1f1dSLionel Sambuc void m(int x = C<int, union int>().f()) {} // expected-error {{declaration of anonymous union must be a definition}} expected-error {{expected a type}} 107*0a6a1f1dSLionel Sambuc }; 108