Home | History | Annotate | Download | only in over.over
      1 // RUN: %clang_cc1 -fsyntax-only %s
      2 
      3 template<typename T> T f0(T);
      4 int f0(int);
      5 
      6 // -- an object or reference being initialized
      7 struct S {
      8   int (*f0)(int);
      9   float (*f1)(float);
     10 };
     11 
     12 void test_init_f0() {
     13   int (*f0a)(int) = f0;
     14   int (*f0b)(int) = &f0;
     15   int (*f0c)(int) = (f0);
     16   float (*f0d)(float) = f0;
     17   float (*f0e)(float) = &f0;
     18   float (*f0f)(float) = (f0);
     19   int (&f0g)(int) = f0;
     20   int (&f0h)(int) = (f0);
     21   float (&f0i)(float) = f0;
     22   float (&f0j)(float) = (f0);
     23   S s = { f0, f0 };
     24 }
     25 
     26 // -- the left side of an assignment (5.17),
     27 void test_assign_f0() {
     28   int (*f0a)(int) = 0;
     29   float (*f0b)(float) = 0;
     30 
     31   f0a = f0;
     32   f0a = &f0;
     33   f0a = (f0);
     34   f0b = f0;
     35   f0b = &f0;
     36   f0b = (f0);
     37 }
     38 
     39 // -- a parameter of a function (5.2.2),
     40 void eat_f0(int a(int), float (*b)(float), int (&c)(int), float (&d)(float));
     41 
     42 void test_pass_f0() {
     43   eat_f0(f0, f0, f0, f0);
     44   eat_f0(&f0, &f0, (f0), (f0));
     45 }
     46 
     47 // -- a parameter of a user-defined operator (13.5),
     48 struct X { };
     49 void operator+(X, int(int));
     50 void operator-(X, float(*)(float));
     51 void operator*(X, int (&)(int));
     52 void operator/(X, float (&)(float));
     53 
     54 void test_operator_pass_f0(X x) {
     55   x + f0;
     56   x + &f0;
     57   x - f0;
     58   x - &f0;
     59   x * f0;
     60   x * (f0);
     61   x / f0;
     62   x / (f0);
     63 }
     64 
     65 // -- the return value of a function, operator function, or conversion (6.6.3),
     66 int (*test_return_f0_a())(int) { return f0; }
     67 int (*test_return_f0_b())(int) { return &f0; }
     68 int (*test_return_f0_c())(int) { return (f0); }
     69 float (*test_return_f0_d())(float) { return f0; }
     70 float (*test_return_f0_e())(float) { return &f0; }
     71 float (*test_return_f0_f())(float) { return (f0); }
     72 
     73 // -- an explicit type conversion (5.2.3, 5.2.9, 5.4), or
     74 void test_convert_f0() {
     75   (void)((int (*)(int))f0);
     76   (void)((int (*)(int))&f0);
     77   (void)((int (*)(int))(f0));
     78   (void)((float (*)(float))f0);
     79   (void)((float (*)(float))&f0);
     80   (void)((float (*)(float))(f0));
     81 }
     82 
     83 // -- a non-type template-parameter(14.3.2).
     84 template<int(int)> struct Y0 { };
     85 template<float(float)> struct Y1 { };
     86 template<int (&)(int)> struct Y2 { };
     87 template<float (&)(float)> struct Y3 { };
     88 
     89 Y0<f0> y0;
     90 Y0<&f0> y0a;
     91 Y1<f0> y1;
     92 Y1<&f0> y1a;
     93 Y2<f0> y2;
     94 Y3<f0> y3;
     95