Home | History | Annotate | Download | only in dcl.fct.default
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 void f0(int i, int j, int k = 3);
      4 void f0(int i, int j, int k);
      5 void f0(int i, int j = 2, int k);
      6 void f0(int i, int j, int k);
      7 void f0(int i = 1, // expected-note{{previous definition}}
      8         int j, int k);
      9 void f0(int i, int j, int k);   // want 2 decls before next default arg
     10 void f0(int i, int j, int k);
     11 
     12 namespace 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 
     20 void test_f0_outer_scope() {
     21   f0(); // okay
     22 }
     23 
     24 void f0(int i = 1, // expected-error{{redefinition of default argument}}
     25         int, int);
     26 
     27 template<typename T> void f1(T); // expected-note{{previous}}
     28 
     29 template<typename T>
     30 void f1(T = T()); // expected-error{{cannot be added}}
     31 
     32 
     33 namespace N1 {
     34   // example from C++03 standard
     35   // FIXME: make these "f2"s into "f"s, then fix our scoping issues
     36   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); // okay
     49     void f(int, int = 5); // expected-error{{redefinition of default argument}}
     50   }
     51 
     52   void n()
     53   {
     54     f2(6); // okay
     55   }
     56 }
     57 
     58 
     59 namespace PR18432 {
     60 
     61 struct A {
     62   struct B {
     63     static void Foo (int = 0);
     64   };
     65 
     66   // should not hide default args
     67   friend void B::Foo (int);
     68 };
     69 
     70 void Test ()
     71 {
     72   A::B::Foo ();
     73 }
     74 
     75 } // namespace
     76