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