cvt.c (cp_convert_to_pointer): Preserve TREE_CONSTANT.

* cvt.c (cp_convert_to_pointer): Preserve TREE_CONSTANT.
	* typeck2.c (initializer_constant_valid_p): Allow conversions
	between pointers and refrerences.

From-SVN: r18119
This commit is contained in:
Jason Merrill 1998-02-19 10:05:22 +00:00 committed by Jason Merrill
parent e62d5b5833
commit 31bcaa204f
3 changed files with 12 additions and 5 deletions

View File

@ -1,3 +1,9 @@
Thu Feb 19 10:04:12 1998 Jason Merrill <jason@yorick.cygnus.com>
* cvt.c (cp_convert_to_pointer): Preserve TREE_CONSTANT.
* typeck2.c (initializer_constant_valid_p): Allow conversions
between pointers and refrerences.
1998-02-19 Brendan Kehoe <brendan@cygnus.com>
* typeck.c (build_unary_op): Only warn about incr/decr a pointer

View File

@ -136,11 +136,10 @@ cp_convert_to_pointer (type, expr)
{
register tree intype = TREE_TYPE (expr);
register enum tree_code form;
tree rval;
if (IS_AGGR_TYPE (intype))
{
tree rval;
intype = complete_type (intype);
if (TYPE_SIZE (intype) == NULL_TREE)
{
@ -282,7 +281,9 @@ cp_convert_to_pointer (type, expr)
return error_mark_node;
}
return build1 (NOP_EXPR, type, expr);
rval = build1 (NOP_EXPR, type, expr);
TREE_CONSTANT (rval) = TREE_CONSTANT (expr);
return rval;
}
my_friendly_assert (form != OFFSET_TYPE, 186);

View File

@ -392,8 +392,8 @@ initializer_constant_valid_p (value, endtype)
case CONVERT_EXPR:
case NOP_EXPR:
/* Allow conversions between pointer types. */
if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE)
if (POINTER_TYPE_P (TREE_TYPE (value))
&& POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
/* Allow conversions between real types. */