Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/gcc.dg/compare5.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/gcc.dg/compare5.c Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,41 @@ +/* Test for a bogus warning on comparison between signed and unsigned. + Origin: Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/21/2001. */ + +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +extern void bar(void); + +int foo(int x, int y, unsigned u) +{ + /* A *_DIV_EXPR is non-negative if both operands are. */ + + if (u < ((x=-22)/33)) /* { dg-warning "different signedness" "DIV_EXPR" } */ + return x; + + if (u < ((x=22)/33)) + return x; + + if (u < ((x=22)/(y=33))) + return x; + + if (u < (((x&0x10000)?128:64) / ((y&0x10000)?8:4))) + return x; + + + /* A *_MOD_EXPR is non-negative if the first operand is. */ + + if (u < ((x=-22)%33)) /* { dg-warning "different signedness" "MOD_EXPR" } */ + return x; + + if (u < ((x=22)%-33)) + return x; + + if (u < ((x==y)%-33)) + return x; + + if (u < (((x=22)/33)%-33)) + return x; + + return 0; +}