diff options
author | Jason Merrill <jason@yorick.cygnus.com> | 1998-08-13 15:26:46 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-08-13 11:26:46 -0400 |
commit | 0d906a5f369e6c35c32c7f5489dd4027c823973e (patch) | |
tree | 3ebba1f35f15621b20d82f27a0859d38b55d307c | |
parent | 6ece24871f3f0bd6b3eaa098be79ca8ca5613f46 (diff) | |
download | gcc-0d906a5f369e6c35c32c7f5489dd4027c823973e.zip gcc-0d906a5f369e6c35c32c7f5489dd4027c823973e.tar.gz gcc-0d906a5f369e6c35c32c7f5489dd4027c823973e.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-typeck.c | 17 |
2 files changed, 17 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bbe6a73..35e2e6c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 4ccc1a3..0a1f490 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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) |