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

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

From-SVN: r21697
This commit is contained in:
Jason Merrill 1998-08-13 15:26:46 +00:00 committed by Jason Merrill
parent 6ece24871f
commit 0d906a5f36
2 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,8 @@
Thu Aug 13 15:24:48 1998 Jason Merrill <jason@yorick.cygnus.com>
* c-typeck.c (initializer_constant_valid_p): Allow conversion of 0
of any size to a pointer.
Thu Aug 13 12:53:13 1998 Jim Wilson <wilson@cygnus.com>
* i386/winnt.c (i386_pe_asm_file_end): Check TREE_SYMBOL_REFERENCED.
@ -567,7 +572,7 @@ Tue Jul 28 22:31:12 1998 Craig Burley <burley@gnu.org>
SUBREG, MEM.
* rtlanal.c (replace_rtx): Prohibit replaces in CONST_DOUBLE.
Tue Jul 28 11:33:09 1998 Mark Mitchell <mark@markmitchell.com>
* cplus-dem.c (type_kind_t): New type.
(demangle_template_value_parm): Add type_kind_t parameter. Rely

View File

@ -4423,13 +4423,18 @@ initializer_constant_valid_p (value, endtype)
return initializer_constant_valid_p (TREE_OPERAND (value, 0),
endtype);
/* Likewise conversions from int to pointers. */
/* 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
&& (TYPE_PRECISION (TREE_TYPE (value))
<= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
return initializer_constant_valid_p (TREE_OPERAND (value, 0),
endtype);
&& 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)