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