Commit 0d906a5f by Jason Merrill Committed by Jason Merrill

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
parent 6ece2487
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
......
......@@ -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)))))
&& 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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment