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]

PATCH Re: c enable-checking failure


Does this seem like an appropriate fix?

Sun Jul 12 01:27:05 1998  Jason Merrill  <jason@yorick.cygnus.com>

	* fold-const.c (non_lvalue): Don't deal with null pointer 
	constants here.
	(fold, case COMPOUND_EXPR): Wrap a constant 0 in a NOP_EXPR.

Index: fold-const.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/fold-const.c,v
retrieving revision 1.42
diff -c -p -r1.42 fold-const.c
*** fold-const.c	1998/06/29 21:39:48	1.42
--- fold-const.c	1998/07/12 08:33:08
*************** fold_convert (t, arg1)
*** 1679,1686 ****
    return t;
  }
  
! /* Return an expr equal to X but certainly not valid as an lvalue.
!    Also make sure it is not valid as an null pointer constant.  */
  
  tree
  non_lvalue (x)
--- 1679,1685 ----
    return t;
  }
  
! /* Return an expr equal to X but certainly not valid as an lvalue.  */
  
  tree
  non_lvalue (x)
*************** non_lvalue (x)
*** 1694,1711 ****
        || TREE_CODE (x) == REAL_CST
        || TREE_CODE (x) == STRING_CST
        || TREE_CODE (x) == ADDR_EXPR)
!     {
!       if (TREE_CODE (x) == INTEGER_CST && integer_zerop (x))
! 	{
! 	  /* Use NOP_EXPR instead of NON_LVALUE_EXPR
! 	     so convert_for_assignment won't strip it.
! 	     This is so this 0 won't be treated as a null pointer constant.  */
! 	  result = build1 (NOP_EXPR, TREE_TYPE (x), x);
! 	  TREE_CONSTANT (result) = TREE_CONSTANT (x);
! 	  return result;
! 	}
!       return x;
!     }
  
    result = build1 (NON_LVALUE_EXPR, TREE_TYPE (x), x);
    TREE_CONSTANT (result) = TREE_CONSTANT (x);
--- 1693,1699 ----
        || TREE_CODE (x) == REAL_CST
        || TREE_CODE (x) == STRING_CST
        || TREE_CODE (x) == ADDR_EXPR)
!     return x;
  
    result = build1 (NON_LVALUE_EXPR, TREE_TYPE (x), x);
    TREE_CONSTANT (result) = TREE_CONSTANT (x);
*************** fold (expr) 
*** 6037,6043 ****
  	return t;
        /* Don't let (0, 0) be null pointer constant.  */
        if (integer_zerop (arg1))
! 	return non_lvalue (arg1);
        return arg1;
  
      case COMPLEX_EXPR:
--- 6025,6031 ----
  	return t;
        /* Don't let (0, 0) be null pointer constant.  */
        if (integer_zerop (arg1))
! 	return build1 (NOP_EXPR, TREE_TYPE (arg1), arg1);
        return arg1;
  
      case COMPLEX_EXPR:


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