From 31bcaa204ff12aad6a553a333e0a72c9b5b1111a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 19 Feb 1998 10:05:22 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cvt.c | 7 ++++--- gcc/cp/typeck2.c | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 370d443..6019bf0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +Thu Feb 19 10:04:12 1998 Jason Merrill + + * 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 * typeck.c (build_unary_op): Only warn about incr/decr a pointer diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 0fdce85..d308805 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index c460f45..6df358a 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -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. */ -- 2.7.4