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