1// RUN: %clang_cc1 -fsyntax-only %s
2
3template<typename T> T f0(T);
4int f0(int);
5
6// -- an object or reference being initialized
7struct S {
8  int (*f0)(int);
9  float (*f1)(float);
10};
11
12void 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),
27void 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),
40void eat_f0(int a(int), float (*b)(float), int (&c)(int), float (&d)(float));
41
42void 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),
48struct X { };
49void operator+(X, int(int));
50void operator-(X, float(*)(float));
51void operator*(X, int (&)(int));
52void operator/(X, float (&)(float));
53
54void 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),
66int (*test_return_f0_a())(int) { return f0; }
67int (*test_return_f0_b())(int) { return &f0; }
68int (*test_return_f0_c())(int) { return (f0); }
69float (*test_return_f0_d())(float) { return f0; }
70float (*test_return_f0_e())(float) { return &f0; }
71float (*test_return_f0_f())(float) { return (f0); }
72
73// -- an explicit type conversion (5.2.3, 5.2.9, 5.4), or
74void 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).
84template<int(int)> struct Y0 { };
85template<float(float)> struct Y1 { };
86template<int (&)(int)> struct Y2 { };
87template<float (&)(float)> struct Y3 { };
88
89Y0<f0> y0;
90Y0<&f0> y0a;
91Y1<f0> y1;
92Y1<&f0> y1a;
93Y2<f0> y2;
94Y3<f0> y3;
95