blob: d3e999c34c6d3f3abbfaaa80c8cadc3848dd478d [file] [log] [blame]
Chris Lattner04421082008-04-08 04:40:51 +00001// RUN: clang -fsyntax-only -verify %s
2void f(int i, int j, int k = 3);
Douglas Gregor6d6eb572008-05-07 04:49:29 +00003void f(int i, int j, int k);
Chris Lattner04421082008-04-08 04:40:51 +00004void f(int i, int j = 2, int k);
Douglas Gregor6d6eb572008-05-07 04:49:29 +00005void f(int i, int j, int k);
Chris Lattner04421082008-04-08 04:40:51 +00006void f(int i = 1, int j, int k);
Douglas Gregor6d6eb572008-05-07 04:49:29 +00007void f(int i, int j, int k);
Chris Lattner04421082008-04-08 04:40:51 +00008
9void i()
10{
11 f();
12 f(0);
13 f(0, 1);
14 f(0, 1, 2);
15}
Chris Lattner8123a952008-04-10 02:22:51 +000016
17
18int f1(int i, int i, int j) { // expected-error {{redefinition of parameter 'i'}}
19 i = 17;
20 return j;
21}
22
23int x;
24void g(int x, int y = x); // expected-error {{default argument references parameter 'x'}}
25
26void h()
27{
28 int i;
29 extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
30}
Chris Lattner9e979552008-04-12 23:52:44 +000031
32void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
Douglas Gregor6d6eb572008-05-07 04:49:29 +000033
34void nondecl(int (*f)(int x = 5)) // {expected-error {{default arguments can only be specified}}}
35{
36 void (*f2)(int = 17) // {expected-error {{default arguments can only be specified}}}
37 = (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
38}