1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li // PR6647 4*67e74705SXin Li class C { 5*67e74705SXin Li // After the error, the rest of the tokens inside the default arg should be 6*67e74705SXin Li // skipped, avoiding a "expected ';' after class" after 'undecl'. 7*67e74705SXin Li void m(int x = undecl + 0); // expected-error {{use of undeclared identifier 'undecl'}} 8*67e74705SXin Li }; 9*67e74705SXin Li 10*67e74705SXin Li typedef struct Inst { 11*67e74705SXin Li void m(int x=0); 12*67e74705SXin Li } *InstPtr; 13*67e74705SXin Li 14*67e74705SXin Li struct X { 15*67e74705SXin Li void f(int x = 1:); // expected-error {{unexpected end of default argument expression}} 16*67e74705SXin Li }; 17*67e74705SXin Li 18*67e74705SXin Li // PR13657 19*67e74705SXin Li struct T { 20*67e74705SXin Li template <typename A, typename B> struct T1 { enum {V};}; 21*67e74705SXin Li template <int A, int B> struct T2 { enum {V}; }; 22*67e74705SXin Li template <int, int> static int func(int); 23*67e74705SXin Li 24*67e74705SXin Li 25*67e74705SXin Li void f1(T1<int, int> = T1<int, int>()); 26*67e74705SXin Li void f2(T1<int, double> = T1<int, double>(), T2<0, 5> = T2<0, 5>()); 27*67e74705SXin Li void f3(int a = T2<0, (T1<int, int>::V > 10) ? 5 : 6>::V, bool b = 4<5 ); 28*67e74705SXin Li void f4(bool a = 1 < 0, bool b = 2 > 0 ); 29*67e74705SXin Li void f5(bool a = 1 > T2<0, 0>::V, bool b = T1<int,int>::V < 3, int c = 0); 30*67e74705SXin Li void f6(bool a = T2<0,3>::V < 4, bool b = 4 > T2<0,3>::V); 31*67e74705SXin Li void f7(bool a = T1<int, bool>::V < 3); 32*67e74705SXin Li void f8(int = func<0,1<2>(0), int = 1<0, T1<int,int>(int) = 0); 33*67e74705SXin Li }; 34*67e74705SXin Li 35*67e74705SXin Li // rdar://18508589 36*67e74705SXin Li struct S { 37*67e74705SXin Li void f(int &r = error); // expected-error {{use of undeclared identifier 'error'}} 38*67e74705SXin Li }; 39*67e74705SXin Li 40*67e74705SXin Li struct U { iU41*67e74705SXin Li void i(int x = ) {} // expected-error{{expected expression}} 42*67e74705SXin Li typedef int *fp(int x = ); // expected-error{{default arguments can only be specified for parameters in a function declaration}} 43*67e74705SXin Li }; 44