[PATCH] Fix PR70747

Richard Biener rguenther@suse.de
Thu Apr 21 09:41:00 GMT 2016


I am testing the following (obvious) patch to fix PR70747.

Richard.

2016-04-21  Richard Biener  <rguenther@suse.de>

	PR middle-end/70747
	* fold-const.c (fold_comparison): Return properly typed
	constant boolean.

	* gcc.dg/pr70747.c: New testcase.

Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c	(revision 235305)
--- gcc/fold-const.c	(working copy)
*************** fold_comparison (location_t loc, enum tr
*** 8676,8686 ****
  	    case EQ_EXPR:
  	    case LE_EXPR:
  	    case LT_EXPR:
! 	      return boolean_false_node;
  	    case GE_EXPR:
  	    case GT_EXPR:
  	    case NE_EXPR:
! 	      return boolean_true_node;
  	    default:
  	      gcc_unreachable ();
  	    }
--- 8686,8696 ----
  	    case EQ_EXPR:
  	    case LE_EXPR:
  	    case LT_EXPR:
! 	      return constant_boolean_node (false, type);
  	    case GE_EXPR:
  	    case GT_EXPR:
  	    case NE_EXPR:
! 	      return constant_boolean_node (true, type);
  	    default:
  	      gcc_unreachable ();
  	    }
Index: gcc/testsuite/gcc.dg/pr70747.c
===================================================================
*** gcc/testsuite/gcc.dg/pr70747.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr70747.c	(working copy)
***************
*** 0 ****
--- 1,10 ----
+ /* { dg-do compile } */
+ /* { dg-options "-pedantic" } */
+ 
+ int *a, b;
+ 
+ void fn1 ()
+ {
+   a = __builtin_malloc (sizeof(int)*2); 
+   b = &a[1] == (0, 0); /* { dg-warning "comparison between pointer and integer" } */
+ }



More information about the Gcc-patches mailing list