Argyrios Kyrtzidis | 998d51b | 2010-03-30 22:14:32 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | // PR6647 |
| 4 | class C { |
| 5 | // After the error, the rest of the tokens inside the default arg should be |
| 6 | // skipped, avoiding a "expected ';' after class" after 'undecl'. |
| 7 | void m(int x = undecl + 0); // expected-error {{use of undeclared identifier 'undecl'}} |
| 8 | }; |
| 9 | |
Argyrios Kyrtzidis | 249179c | 2010-08-06 09:47:24 +0000 | [diff] [blame] | 10 | typedef struct Inst { |
| 11 | void m(int x=0); |
| 12 | } *InstPtr; |
Argyrios Kyrtzidis | c0dc36b | 2010-08-09 21:08:13 +0000 | [diff] [blame] | 13 | |
| 14 | struct X { |
| 15 | void f(int x = 1:); // expected-error {{unexpected end of default argument expression}} |
| 16 | }; |
Richard Smith | 1fff95c | 2013-09-12 23:28:08 +0000 | [diff] [blame] | 17 | |
| 18 | // PR13657 |
| 19 | struct T { |
| 20 | template <typename A, typename B> struct T1 { enum {V};}; |
| 21 | template <int A, int B> struct T2 { enum {V}; }; |
| 22 | template <int, int> static int func(int); |
| 23 | |
| 24 | |
| 25 | void f1(T1<int, int> = T1<int, int>()); |
| 26 | void f2(T1<int, double> = T1<int, double>(), T2<0, 5> = T2<0, 5>()); |
| 27 | void f3(int a = T2<0, (T1<int, int>::V > 10) ? 5 : 6>::V, bool b = 4<5 ); |
| 28 | void f4(bool a = 1 < 0, bool b = 2 > 0 ); |
| 29 | void f5(bool a = 1 > T2<0, 0>::V, bool b = T1<int,int>::V < 3, int c = 0); |
| 30 | void f6(bool a = T2<0,3>::V < 4, bool b = 4 > T2<0,3>::V); |
| 31 | void f7(bool a = T1<int, bool>::V < 3); |
| 32 | void f8(int = func<0,1<2>(0), int = 1<0, T1<int,int>(int) = 0); |
| 33 | }; |
Fariborz Jahanian | 56b11ca8 | 2014-10-01 21:33:22 +0000 | [diff] [blame] | 34 | |
| 35 | // rdar://18508589 |
| 36 | struct S { |
| 37 | void f(int &r = error); // expected-error {{use of undeclared identifier 'error'}} |
| 38 | }; |
David Majnemer | 906ed27 | 2015-01-13 05:28:24 +0000 | [diff] [blame^] | 39 | |
| 40 | struct U { |
| 41 | void i(int x = ) {} // expected-error{{expected expression}} |
| 42 | }; |