109 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 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); // want 2 decls before next default arg10void f0(int i, int j, int k);11 12namespace N0 {13 void f0(int, int, int); // expected-note{{candidate}}14 15 void test_f0_inner_scope() {16 f0(); // expected-error{{no matching}}17 }18}19 20void test_f0_outer_scope() {21 f0(); // okay22}23 24void f0(int i = 1, // expected-error{{redefinition of default argument}}25 int, int); 26 27template<typename T> void f1(T); // expected-note{{previous}}28 29template<typename T>30void f1(T = T()); // expected-error{{cannot be added}}31 32 33namespace N1 {34 // example from C++03 standard35 // FIXME: make these "f2"s into "f"s, then fix our scoping issues36 void f2(int, int); 37 void f2(int, int = 7); 38 void h() {39 f2(3); // OK, calls f(3, 7) 40 void f(int = 1, int); // expected-error{{missing default argument}}41 }42 43 void m()44 {45 void f(int, int); // expected-note{{'f' declared here}}46 f(4); // expected-error{{too few arguments to function call}}47 void f(int, int = 5); // expected-note{{previous definition}}48 f(4); // okay49 void f(int, int = 5); // expected-error{{redefinition of default argument}}50 }51 52 void n()53 {54 f2(6); // okay55 }56}57 58 59namespace PR18432 {60 61struct A {62 struct B {63 static void Foo (int = 0);64 };65 66 // should not hide default args67 friend void B::Foo (int);68};69 70void Test ()71{72 A::B::Foo ();73}74 75} // namespace76 77namespace pr12724 {78 79void func_01(bool param = true);80class C01 {81public:82 friend void func_01(bool param);83};84 85void func_02(bool param = true);86template<typename T>87class C02 {88public:89 friend void func_02(bool param);90};91C02<int> c02;92 93void func_03(bool param);94template<typename T>95class C03 {96public:97 friend void func_03(bool param);98};99void func_03(bool param = true);100C03<int> c03;101 102void main() {103 func_01();104 func_02();105 func_03();106}107 108} // namespace pr12724109