Mercurial > hg > CbC > CbC_llvm
comparison clang/test/Sema/warn-bad-function-cast.c @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 1d019706d866 |
children |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
1 // RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wbad-function-cast -triple x86_64-unknown-unknown -verify | 1 // RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wbad-function-cast -ffixed-point -triple x86_64-unknown-unknown -verify |
2 // rdar://9103192 | 2 // rdar://9103192 |
3 | 3 |
4 void vf(void); | 4 void vf(void); |
5 int if1(void); | 5 int if1(void); |
6 char if2(void); | 6 char if2(void); |
10 _Complex double cf(void); | 10 _Complex double cf(void); |
11 enum e { E1 } ef(void); | 11 enum e { E1 } ef(void); |
12 _Bool bf(void); | 12 _Bool bf(void); |
13 char *pf1(void); | 13 char *pf1(void); |
14 int *pf2(void); | 14 int *pf2(void); |
15 _Fract ff1(void); | |
15 | 16 |
16 void | 17 void |
17 foo(void) | 18 foo(void) |
18 { | 19 { |
20 | |
21 /* default, no cast, should always be ok */ | |
22 ff1(); | |
19 /* Casts to void types are always OK. */ | 23 /* Casts to void types are always OK. */ |
20 (void)vf(); | 24 (void)vf(); |
21 (void)if1(); | 25 (void)if1(); |
22 (void)cf(); | 26 (void)cf(); |
23 (const void)bf(); | 27 (const void)bf(); |
28 (void)ff1(); | |
24 /* Casts to the same type or similar types are OK. */ | 29 /* Casts to the same type or similar types are OK. */ |
25 (int)if1(); | 30 (int)if1(); |
26 (long)if2(); | 31 (long)if2(); |
27 (char)if3(); | 32 (char)if3(); |
28 (float)rf1(); | 33 (float)rf1(); |
30 (_Complex float)cf(); | 35 (_Complex float)cf(); |
31 (enum f { F1 })ef(); | 36 (enum f { F1 })ef(); |
32 (_Bool)bf(); | 37 (_Bool)bf(); |
33 (void *)pf1(); | 38 (void *)pf1(); |
34 (char *)pf2(); | 39 (char *)pf2(); |
40 (_Fract) ff1(); | |
35 /* All following casts issue warning */ | 41 /* All following casts issue warning */ |
36 (float)if1(); /* expected-warning {{cast from function call of type 'int' to non-matching type 'float'}} */ | 42 (float)if1(); /* expected-warning {{cast from function call of type 'int' to non-matching type 'float'}} */ |
37 (double)if2(); /* expected-warning {{cast from function call of type 'char' to non-matching type 'double'}} */ | 43 (double)if2(); /* expected-warning {{cast from function call of type 'char' to non-matching type 'double'}} */ |
38 (_Bool)if3(); /* expected-warning {{cast from function call of type 'long' to non-matching type '_Bool'}} */ | 44 (_Bool)if3(); /* expected-warning {{cast from function call of type 'long' to non-matching type '_Bool'}} */ |
39 (int)rf1(); /* expected-warning {{cast from function call of type 'float' to non-matching type 'int'}} */ | 45 (int)rf1(); /* expected-warning {{cast from function call of type 'float' to non-matching type 'int'}} */ |
41 (double)cf(); /* expected-warning {{cast from function call of type '_Complex double' to non-matching type 'double'}} */ | 47 (double)cf(); /* expected-warning {{cast from function call of type '_Complex double' to non-matching type 'double'}} */ |
42 (int)ef(); /* expected-warning {{cast from function call of type 'enum e' to non-matching type 'int'}} */ | 48 (int)ef(); /* expected-warning {{cast from function call of type 'enum e' to non-matching type 'int'}} */ |
43 (int)bf(); /* expected-warning {{cast from function call of type '_Bool' to non-matching type 'int'}} */ | 49 (int)bf(); /* expected-warning {{cast from function call of type '_Bool' to non-matching type 'int'}} */ |
44 (__SIZE_TYPE__)pf1(); /* expected-warning {{cast from function call of type 'char *' to non-matching type 'unsigned long'}} */ | 50 (__SIZE_TYPE__)pf1(); /* expected-warning {{cast from function call of type 'char *' to non-matching type 'unsigned long'}} */ |
45 (__PTRDIFF_TYPE__)pf2(); /* expected-warning {{cast from function call of type 'int *' to non-matching type 'long'}} */ | 51 (__PTRDIFF_TYPE__)pf2(); /* expected-warning {{cast from function call of type 'int *' to non-matching type 'long'}} */ |
52 (_Fract) if1(); /* expected-warning{{cast from function call of type 'int' to non-matching type '_Fract'}} */ | |
53 (int)ff1(); /* expected-warning{{cast from function call of type '_Fract' to non-matching type 'int'}} */ | |
46 } | 54 } |
47 | 55 |