p4.cpp revision 9aab1489866a5afe1a8a3267f9ad7124034fd644
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
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  {
44    void f(int, int); // expected-note{{'f' declared here}}
45    f(4);  // expected-error{{too few arguments to function call}}
46    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  }
55}
56