blob: f3dec52f63b39e3784a6688d5c4e6a2721b14d0b [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor6cc15182009-09-11 18:44:32 +00002
3void f0(int i, int j, int k = 3);
4void f0(int i, int j, int k);
5void f0(int i, int j = 2, int k);
6void f0(int i, int j, int k);
7void f0(int i = 1, // expected-note{{previous definition}}
8 int j, int k);
9void f0(int i, int j, int k);
10
11namespace N0 {
12 void f0(int, int, int); // expected-note{{candidate}}
13
14 void test_f0_inner_scope() {
15 f0(); // expected-error{{no matching}}
16 }
17}
18
19void test_f0_outer_scope() {
20 f0(); // okay
21}
22
23void f0(int i = 1, // expected-error{{redefinition of default argument}}
24 int, int);
25
26template<typename T> void f1(T); // expected-note{{previous}}
27
28template<typename T>
29void f1(T = T()); // expected-error{{cannot be added}}
30
31
32namespace N1 {
33 // example from C++03 standard
34 // FIXME: make these "f2"s into "f"s, then fix our scoping issues
35 void f2(int, int);
36 void f2(int, int = 7);
37 void h() {
38 f2(3); // OK, calls f(3, 7)
39 void f(int = 1, int); // expected-error{{missing default argument}}
40 }
41
42 void m()
43 {
Peter Collingbourne9aab1482011-07-29 00:24:42 +000044 void f(int, int); // expected-note{{'f' declared here}}
John McCallba135432009-11-21 08:51:07 +000045 f(4); // expected-error{{too few arguments to function call}}
Douglas Gregor6cc15182009-09-11 18:44:32 +000046 void f(int, int = 5); // expected-note{{previous definition}}
47 f(4); // okay
48 void f(int, int = 5); // expected-error{{redefinition of default argument}}
49 }
50
51 void n()
52 {
53 f2(6); // okay
54 }
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000055}