diff options
author | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
commit | 056abd2059c65a3e908193aeae16fad98017437c (patch) | |
tree | 2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /test/Sema/warn-bad-function-cast.c | |
parent | cc73504950eb7b5dff2dded9bedd67bc36d64641 (diff) | |
download | FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.zip FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.tar.gz |
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):
http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974
Diffstat (limited to 'test/Sema/warn-bad-function-cast.c')
-rw-r--r-- | test/Sema/warn-bad-function-cast.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/Sema/warn-bad-function-cast.c b/test/Sema/warn-bad-function-cast.c new file mode 100644 index 0000000..41a3f78 --- /dev/null +++ b/test/Sema/warn-bad-function-cast.c @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wbad-function-cast -triple x86_64-unknown-unknown -verify +// rdar://9103192 + +void vf(void); +int if1(void); +char if2(void); +long if3(void); +float rf1(void); +double rf2(void); +_Complex double cf(void); +enum e { E1 } ef(void); +_Bool bf(void); +char *pf1(void); +int *pf2(void); + +void +foo(void) +{ + /* Casts to void types are always OK. */ + (void)vf(); + (void)if1(); + (void)cf(); + (const void)bf(); + /* Casts to the same type or similar types are OK. */ + (int)if1(); + (long)if2(); + (char)if3(); + (float)rf1(); + (long double)rf2(); + (_Complex float)cf(); + (enum f { F1 })ef(); + (_Bool)bf(); + (void *)pf1(); + (char *)pf2(); + /* All following casts issue warning */ + (float)if1(); /* expected-warning {{cast from function call of type 'int' to non-matching type 'float'}} */ + (double)if2(); /* expected-warning {{cast from function call of type 'char' to non-matching type 'double'}} */ + (_Bool)if3(); /* expected-warning {{cast from function call of type 'long' to non-matching type '_Bool'}} */ + (int)rf1(); /* expected-warning {{cast from function call of type 'float' to non-matching type 'int'}} */ + (long)rf2(); /* expected-warning {{cast from function call of type 'double' to non-matching type 'long'}} */ + (double)cf(); /* expected-warning {{cast from function call of type '_Complex double' to non-matching type 'double'}} */ + (int)ef(); /* expected-warning {{cast from function call of type 'enum e' to non-matching type 'int'}} */ + (int)bf(); /* expected-warning {{cast from function call of type '_Bool' to non-matching type 'int'}} */ + (__SIZE_TYPE__)pf1(); /* expected-warning {{cast from function call of type 'char *' to non-matching type 'unsigned long'}} */ + (__PTRDIFF_TYPE__)pf2(); /* expected-warning {{cast from function call of type 'int *' to non-matching type 'long'}} */ +} + |