diff options
author | Marek Polacek <polacek@redhat.com> | 2014-01-23 21:01:08 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-01-23 21:01:08 +0000 |
commit | 393e8e8b0ca526d8909ace6303785dd522b1c8ce (patch) | |
tree | 98eae88584be77108a2375e808287ccd88b48a78 /gcc/testsuite/gcc.dg/pr59846.c | |
parent | 6e23f2967868d307d367385411a5e61e6de2c02b (diff) | |
download | gcc-393e8e8b0ca526d8909ace6303785dd522b1c8ce.zip gcc-393e8e8b0ca526d8909ace6303785dd522b1c8ce.tar.gz gcc-393e8e8b0ca526d8909ace6303785dd522b1c8ce.tar.bz2 |
re PR c/59846 (Imprecise column number for -Wtype-limits)
PR c/59846
c-family/
* c-common.c (shorten_compare): Add location_t parameter.
* c-common.h (shorten_binary_op): Adjust declaration.
cp/
* typeck.c (cp_build_binary_op): Pass location to shorten_compare.
c/
* c-typeck.c (parser_build_binary_op): Use location instead of
input_location.
(build_binary_op): Pass location to shorten_compare.
testsuite/
* gcc.dg/pr59846.c: New test.
From-SVN: r207008
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr59846.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/pr59846.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr59846.c b/gcc/testsuite/gcc.dg/pr59846.c new file mode 100644 index 0000000..e002fba --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr59846.c @@ -0,0 +1,39 @@ +/* PR c/59846 */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-op -Wtype-limits" } */ + +_Bool +fn1 (unsigned int p) +{ + return 0UL > p; /* { dg-warning "14:comparison is always false due to limited range of data type" } */ +} + +_Bool +fn2 (unsigned int p) +{ + return 0UL <= p; /* { dg-warning "14:comparison is always true due to limited range of data type" } */ +} + +_Bool +fn3 (unsigned int p) +{ + return p >= 0U; /* { dg-warning "12:comparison of unsigned expression >= 0 is always true" } */ +} + +_Bool +fn4 (unsigned int p) +{ + return p < 0U; /* { dg-warning "12:comparison of unsigned expression < 0 is always false" } */ +} + +_Bool +fn5 (_Bool p) +{ + return p || !p; /* { dg-warning "12:logical" } */ +} + +_Bool +fn6 (_Bool p) +{ + return p && !p; /* { dg-warning "12:logical" } */ +} |