]> gcc.gnu.org Git - gcc.git/commitdiff
cvt.c (cp_convert_to_pointer): Preserve TREE_CONSTANT.
authorJason Merrill <jason@yorick.cygnus.com>
Thu, 19 Feb 1998 10:05:22 +0000 (10:05 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 19 Feb 1998 10:05:22 +0000 (05:05 -0500)
* 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
gcc/cp/cvt.c
gcc/cp/typeck2.c

index 370d443d7b8fcb019e84007b251571f72d0fd63a..6019bf0e0e381f1ef889920cc678f9226f016199 100644 (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
index 0fdce85726dd29411f93eeaa558824da16192b2d..d308805aa62e175108114e689bed2562acd42619 100644 (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);
index c460f45652690f9a29f24350b942717424b7e841..6df358a96021218181721fea1ebb96c941f6a25a 100644 (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.  */
This page took 0.081629 seconds and 5 git commands to generate.