brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 0172c9b Raw
55 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wbad-function-cast -ffixed-point -triple x86_64-unknown-unknown -verify2 3void vf(void);4int if1(void);5char if2(void);6long if3(void);7float rf1(void);8double rf2(void);9_Complex double cf(void);10enum e { E1 } ef(void);11_Bool bf(void);12char *pf1(void);13int *pf2(void);14_Fract ff1(void);15 16void17foo(void)18{19 20  /* default, no cast, should always be ok */21  ff1();22  /* Casts to void types are always OK.  */23  (void)vf();24  (void)if1();25  (void)cf();26  (const void)bf();27  (void)ff1();28  /* Casts to the same type or similar types are OK.  */29  (int)if1();30  (long)if2();31  (char)if3();32  (float)rf1();33  (long double)rf2();34  (_Complex float)cf();35  (enum f { F1 })ef();36  (_Bool)bf();37  (void *)pf1();38  (char *)pf2();39  (_Fract) ff1();40  /* All following casts issue warning */41  (float)if1(); /* expected-warning {{cast from function call of type 'int' to non-matching type 'float'}} */42  (double)if2(); /* expected-warning {{cast from function call of type 'char' to non-matching type 'double'}} */43  (_Bool)if3(); /* expected-warning {{cast from function call of type 'long' to non-matching type '_Bool'}} */44  (int)rf1(); /* expected-warning {{cast from function call of type 'float' to non-matching type 'int'}} */45  (long)rf2(); /* expected-warning {{cast from function call of type 'double' to non-matching type 'long'}} */46  (double)cf(); /* expected-warning {{cast from function call of type '_Complex double' to non-matching type 'double'}} */47  (int)ef(); /* expected-warning {{cast from function call of type 'enum e' to non-matching type 'int'}} */48  (int)bf(); /* expected-warning {{cast from function call of type '_Bool' to non-matching type 'int'}} */49  (__SIZE_TYPE__)pf1(); /* expected-warning {{cast from function call of type 'char *' to non-matching type 'unsigned long'}} */50  (__PTRDIFF_TYPE__)pf2(); /* expected-warning {{cast from function call of type 'int *' to non-matching type 'long'}} */51  (_Fract) if1();          /* expected-warning{{cast from function call of type 'int' to non-matching type '_Fract'}} */52  (int)ff1();              /* expected-warning{{cast from function call of type '_Fract' to non-matching type 'int'}} */53}54 55