diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-04 21:45:41 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-04 21:45:41 +0000 |
commit | c44afe236f0730770ee0bdecddd7da1c5af78568 (patch) | |
tree | 09a78feaae42dbb50fdaf694eca604caa1029b35 /gcc/testsuite/gcc.dg/format | |
parent | 47df1c9677402c981e86b840fac7588edad95afc (diff) | |
download | gcc-c44afe236f0730770ee0bdecddd7da1c5af78568.tar.gz |
* c-common.c (binary_op_error): Do not allow NOP_EXPR.
(c_common_truthvalue_conversion): Handle NOP_EXPR the same as
CONVERT_EXPR.
(check_function_arguments_recurse): Allow both NOP_EXPR and
CONVERT_EXPR but check conversions preserve precision.
* c-typeck.c (pointer_diff): Allow both NOP_EXPR and CONVERT_EXPR
but check conversions preserve precision.
(build_unary_op): Don't allow NOP_EXPR. Use gcc_unreachable () in
default case.
testsuite:
* gcc.dg/format/cast-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108020 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/format')
-rw-r--r-- | gcc/testsuite/gcc.dg/format/cast-1.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/cast-1.c b/gcc/testsuite/gcc.dg/format/cast-1.c new file mode 100644 index 00000000000..78a4f527d9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/cast-1.c @@ -0,0 +1,16 @@ +/* Test for strings cast through integer types: should not be treated + as format strings unless the types are of the same width as + pointers (intptr_t or similar). */ +/* Origin: Joseph Myers <joseph@codesourcery.com> */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +#include "format.h" + +void +f (int x) +{ + printf("%s", x); /* { dg-warning "format" } */ + printf((char *)(size_t)"%s", x); /* { dg-warning "format" } */ + printf((char *)(char)"%s", x); +} |