1 | //RUN: %clang_cc1 -fsyntax-only -verify %s |
2 | |
3 | namespace PR16570 { |
4 | int f1(int, int); |
5 | int f2(const int, int); |
6 | int f3(int&, int); |
7 | int f4(const int&, int); |
8 | |
9 | void good() { |
10 | int(*g1)(int, int) = f1; |
11 | int(*g2)(const int, int) = f1; |
12 | int(*g3)(volatile int, int) = f1; |
13 | int(*g4)(int, int) = f2; |
14 | int(*g5)(const int, int) = f2; |
15 | int(*g6)(volatile int, int) = f2; |
16 | int(*g7)(int&, int) = f3; |
17 | int(*g8)(const int&, int) = f4; |
18 | } |
19 | |
20 | void bad() { |
21 | void (*g1)(int, int) = f1; |
22 | // expected-error@-1 {{different return type ('void' vs 'int'}} |
23 | const int (*g2)(int, int) = f1; |
24 | // expected-error@-1 {{different return type ('const int' vs 'int')}} |
25 | |
26 | int (*g3)(char, int) = f1; |
27 | // expected-error@-1 {{type mismatch at 1st parameter ('char' vs 'int')}} |
28 | int (*g4)(int, char) = f1; |
29 | // expected-error@-1 {{type mismatch at 2nd parameter ('char' vs 'int')}} |
30 | |
31 | int (*g5)(int) = f1; |
32 | // expected-error@-1 {{different number of parameters (1 vs 2)}} |
33 | |
34 | int (*g6)(int, int, int) = f1; |
35 | // expected-error@-1 {{different number of parameters (3 vs 2)}} |
36 | |
37 | int (*g7)(const int, char) = f1; |
38 | // expected-error@-1 {{type mismatch at 2nd parameter ('char' vs 'int')}} |
39 | int (*g8)(int, char) = f2; |
40 | // expected-error@-1 {{type mismatch at 2nd parameter ('char' vs 'int')}} |
41 | int (*g9)(const int&, char) = f3; |
42 | // expected-error@-1 {{type mismatch at 1st parameter ('const int &' vs 'int &')}} |
43 | int (*g10)(int&, char) = f4; |
44 | // expected-error@-1 {{type mismatch at 1st parameter ('int &' vs 'const int &')}} |
45 | } |
46 | |
47 | typedef void (*F)(const char * __restrict__, int); |
48 | void g(const char *, unsigned); |
49 | F f = g; |
50 | // expected-error@-1 {{type mismatch at 2nd parameter ('int' vs 'unsigned int')}} |
51 | |
52 | } |
53 | |