1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s 26cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 36cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f0(int i, int j, int k = 3); 46cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f0(int i, int j, int k); 56cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f0(int i, int j = 2, int k); 66cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f0(int i, int j, int k); 76cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f0(int i = 1, // expected-note{{previous definition}} 86cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor int j, int k); 96cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f0(int i, int j, int k); 106cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 116cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregornamespace N0 { 126cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void f0(int, int, int); // expected-note{{candidate}} 136cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 146cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void test_f0_inner_scope() { 156cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor f0(); // expected-error{{no matching}} 166cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor } 176cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor} 186cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 196cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid test_f0_outer_scope() { 206cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor f0(); // okay 216cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor} 226cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 236cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f0(int i = 1, // expected-error{{redefinition of default argument}} 246cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor int, int); 256cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 266cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregortemplate<typename T> void f1(T); // expected-note{{previous}} 276cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 286cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregortemplate<typename T> 296cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregorvoid f1(T = T()); // expected-error{{cannot be added}} 306cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 316cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 326cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregornamespace N1 { 336cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor // example from C++03 standard 346cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor // FIXME: make these "f2"s into "f"s, then fix our scoping issues 356cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void f2(int, int); 366cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void f2(int, int = 7); 376cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void h() { 386cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor f2(3); // OK, calls f(3, 7) 396cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void f(int = 1, int); // expected-error{{missing default argument}} 406cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor } 416cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 426cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void m() 436cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor { 449aab1489866a5afe1a8a3267f9ad7124034fd644Peter Collingbourne void f(int, int); // expected-note{{'f' declared here}} 45ba13543329afac4a0d01304ec2ec4924d99306a6John McCall f(4); // expected-error{{too few arguments to function call}} 466cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void f(int, int = 5); // expected-note{{previous definition}} 476cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor f(4); // okay 486cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void f(int, int = 5); // expected-error{{redefinition of default argument}} 496cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor } 506cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor 516cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor void n() 526cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor { 536cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor f2(6); // okay 546cc1518b9f15ca846b8c35518eeae9557935678dDouglas Gregor } 554fcfde4d5c8f25e40720972a5543d538a0dcb220Daniel Dunbar} 56