1 // RUN: %clang_cc1 -x c++ %s -fblocks -fsyntax-only -Wcast-function-type -triple x86_64-- -verify 2 3 int x(long); 4 5 typedef int (f1)(long); 6 typedef int (f2)(void*); 7 typedef int (f3)(...); 8 typedef void (f4)(...); 9 typedef void (f5)(void); 10 typedef int (f6)(long, int); 11 typedef int (f7)(long,...); 12 typedef int (&f8)(long, int); 13 14 f1 *a; 15 f2 *b; 16 f3 *c; 17 f4 *d; 18 f5 *e; 19 f6 *f; 20 f7 *g; 21 22 struct S 23 { 24 void foo (int*); 25 void bar (int); 26 }; 27 28 typedef void (S::*mf)(int); 29 30 void foo() { 31 a = (f1 *)x; 32 b = (f2 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function type}} */ 33 b = reinterpret_cast<f2 *>(x); /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function type}} */ 34 c = (f3 *)x; 35 d = (f4 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f4 *' (aka 'void (*)(...)') converts to incompatible function type}} */ 36 e = (f5 *)x; 37 f = (f6 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function type}} */ 38 g = (f7 *)x; 39 40 mf p1 = (mf)&S::foo; /* expected-warning {{cast from 'void (S::*)(int *)' to 'mf' (aka 'void (S::*)(int)') converts to incompatible function type}} */ 41 42 f8 f2 = (f8)x; /* expected-warning {{cast from 'int (long)' to 'f8' (aka 'int (&)(long, int)') converts to incompatible function type}} */ 43 (void)f2; 44 45 int (^y)(long); 46 f = (f6 *)y; /* expected-warning {{cast from 'int (^)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function type}} */ 47 } 48