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 to initializer_constant_valid_p


This is not necessary for the release; it's just for symmetry with the C++
frontend.

Tue Jul 28 13:45:52 1998  Jason Merrill  <jason@dot.cygnus.com>

	* c-typeck.c (initializer_constant_valid_p): Allow conversion of 0
	of any size to a pointer.

Index: c-typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-typeck.c,v
retrieving revision 1.18
diff -c -p -r1.18 c-typeck.c
*** c-typeck.c	1998/06/19 22:27:35	1.18
--- c-typeck.c	1998/07/28 20:46:55
*************** initializer_constant_valid_p (value, end
*** 4423,4435 ****
  	return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  					     endtype);
  
!       /* Likewise conversions from int to pointers.  */
        if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
! 	  && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
! 	  && (TYPE_PRECISION (TREE_TYPE (value))
! 	      <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
! 	return initializer_constant_valid_p (TREE_OPERAND (value, 0),
! 					     endtype);
  
        /* Allow conversions to union types if the value inside is okay.  */
        if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)
--- 4423,4440 ----
  	return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  					     endtype);
  
!       /* Likewise conversions from int to pointers, but also allow
! 	 conversions from 0.  */
        if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
! 	  && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE)
! 	{
! 	  if (integer_zerop (TREE_OPERAND (value, 0)))
! 	    return null_pointer_node;
! 	  else if (TYPE_PRECISION (TREE_TYPE (value))
! 		   <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))))
! 	    return initializer_constant_valid_p (TREE_OPERAND (value, 0),
! 						 endtype);
! 	}
  
        /* Allow conversions to union types if the value inside is okay.  */
        if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)

--NAB10876.901658890/dot.cygnus.com--



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