This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bogus signed/unsigned warning


Hello,

this is my first submission, so if I mixed anything up with the 
formal process, please bear with me.
I would like to contribute more in the future. I gather that I need 
to sign a copyright assignment for that. Where do I get one, and whom 
do I send it to?

As to the patch, I have also changed the appropriate testcases to no
longer expect failure.
Is this the proper approach, or should this be done at a later stage?

Description:
gcc used to issue bogus warnings with -Wsign-compare if one of the 
operands was a statement expression. This caused testcases 10 and 12 in
gcc.dg/compare2.c to fail.

ChangeLog:
2002-08-26  Ansgar Esztermann  <ansgar@thphy.uni-duesseldorf.de>

        * fold-const.c (tree_expr_nonnegative_p): Handle statement 
		  expressions.

		* gcc.dg/compare2.c Removed xfail from cases 10 and 12.

Testing:
make bootstrap on i686-pc-linux-gnu succeeded.
make check yielded the same results as before, except for the two 
testcases mentioned above.

Patch:

Index: gcc/fold-const.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.219
diff -c -3 -p -r1.219 fold-const.c
*** gcc/fold-const.c	22 Aug 2002 00:42:39 -0000	1.219
--- gcc/fold-const.c	26 Aug 2002 15:02:02 -0000
*************** Software Foundation, 59 Temple Place - S
*** 46,51 ****
--- 46,52 ----
  #include "system.h"
  #include "flags.h"
  #include "tree.h"
+ #include "c-common.h"
  #include "real.h"
  #include "rtl.h"
  #include "expr.h"
*************** tree_expr_nonnegative_p (t)
*** 7341,7346 ****
--- 7342,7356 ----
        return tree_expr_nonnegative_p (TREE_OPERAND (t, 0));
      case RTL_EXPR:
        return rtl_expr_nonnegative_p (RTL_EXPR_RTL (t));
+     case STMT_EXPR:
+ 	  t=COMPOUND_BODY(STMT_EXPR_STMT(t));
+ 
+ 	  /* Find the last statement in the chain, ignoring the final
+ 	   * scope statement */
+       while (TREE_CHAIN (t) != NULL_TREE && 
+ 			  	TREE_CODE (TREE_CHAIN (t)) != SCOPE_STMT)
+         t=TREE_CHAIN (t);
+       return tree_expr_nonnegative_p (TREE_OPERAND (t, 0));
  
      default:
        if (truth_value_p (TREE_CODE (t)))
Index: gcc/testsuite/gcc.dg/compare2.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/testsuite/gcc.dg/compare2.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 compare2.c
*** gcc/testsuite/gcc.dg/compare2.c	19 Sep 2000 07:33:44 -0000	1.5
--- gcc/testsuite/gcc.dg/compare2.c	26 Aug 2002 15:02:07 -0000
*************** void f(int x, unsigned int y)
*** 26,36 ****
  
    /* Statement expression.  */
    x > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 9" } */
!   y > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 10" { xfail *-*-* } } */
  
    /* Statement expression with recursive ?: .  */
    x > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 11" } */
!   y > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 12" { xfail *-*-* } } */
  
    /* Statement expression with signed ?:.  */
    x > ({tf; tf?64:-1;}); /* { dg-bogus "signed and unsigned" "case 13" } */
--- 26,36 ----
  
    /* Statement expression.  */
    x > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 9" } */
!   y > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 10" } */
  
    /* Statement expression with recursive ?: .  */
    x > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 11" } */
!   y > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 12" } */
  
    /* Statement expression with signed ?:.  */
    x > ({tf; tf?64:-1;}); /* { dg-bogus "signed and unsigned" "case 13" } */



Ansgar

-- 
Institut fuer theoretische Physik II    | Geb. 25.32.02                           
Heinrich-Heine-Universitaet Duesseldorf | +49-211-8112059 (phone)
Universitaetsstr. 1                     | +49-211-8112262 (fax)
D-40225 Duesseldorf, Germany            | 







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]