Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | void f(int i, int j, int k = 3); |
| 3 | void f(int i, int j = 2, int k); |
| 4 | void f(int i = 1, int j, int k); |
| 5 | |
| 6 | void i() |
| 7 | { |
| 8 | f(); |
| 9 | f(0); |
| 10 | f(0, 1); |
| 11 | f(0, 1, 2); |
| 12 | } |
Chris Lattner | 8123a95 | 2008-04-10 02:22:51 +0000 | [diff] [blame] | 13 | |
| 14 | |
| 15 | int f1(int i, int i, int j) { // expected-error {{redefinition of parameter 'i'}} |
| 16 | i = 17; |
| 17 | return j; |
| 18 | } |
| 19 | |
| 20 | int x; |
| 21 | void g(int x, int y = x); // expected-error {{default argument references parameter 'x'}} |
| 22 | |
| 23 | void h() |
| 24 | { |
| 25 | int i; |
| 26 | extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}} |
| 27 | } |
Chris Lattner | 9e97955 | 2008-04-12 23:52:44 +0000 | [diff] [blame^] | 28 | |
| 29 | void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}} |