[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / warn-cast-function-type.c
blob5d823df27ee5359c0e583a8ec3cb04002ca9637b
1 // RUN: %clang_cc1 -x c %s -fsyntax-only -Wcast-function-type -triple x86_64-- -verify
3 int x(long);
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,...);
13 f1 *a;
14 f2 *b;
15 f3 *c;
16 f4 *d;
17 f5 *e;
18 f6 *f;
19 f7 *g;
21 void foo(void) {
22 a = (f1 *)x;
23 b = (f2 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function type}} */
24 c = (f3 *)x;
25 d = (f4 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f4 *' (aka 'void (*)()') converts to incompatible function type}} */
26 e = (f5 *)x;
27 f = (f6 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function type}} */
28 g = (f7 *)x;