parse.y (fold_constant_for_init): If a VAR_DECL, convert numerical constant to the...
authorPer Bothner <per@bothner.com>
Wed, 11 Sep 2002 19:53:14 +0000 (12:53 -0700)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 11 Sep 2002 19:53:14 +0000 (19:53 +0000)
2002-09-11  Per Bothner  <per@bothner.com>

* parse.y (fold_constant_for_init):  If a VAR_DECL, convert numerical
constant to the type of the field.
(java_complete_tree):  Remove now-redundant code.

* parse.y (fold_constant_for_init):  'null' is not a constant expr.

From-SVN: r57036

gcc/java/ChangeLog
gcc/java/parse.y

index 63d036a53e43d46f66ab881422260b3af3833577..2defb3301aadc331f6b06205505f756bfc259cb1 100644 (file)
@@ -1,3 +1,11 @@
+2002-09-11  Per Bothner  <per@bothner.com>
+
+       * parse.y (fold_constant_for_init):  If a VAR_DECL, convert numerical
+       constant to the type of the field.
+       (java_complete_tree):  Remove now-redundant code.
+
+       * parse.y (fold_constant_for_init):  'null' is not a constant expr.
+
 2002-09-03  Jesse Rosenstock  <jmr@ugcs.caltech.edu>
 
        For PR java/5794:
index aa593f9f072d2664a666d45a60c47dc5d4e35a3b..2112b717da0f329119a1c10e14b541ebf2819499 100644 (file)
@@ -11509,22 +11509,9 @@ java_complete_tree (node)
       && DECL_INITIAL (node) != NULL_TREE
       && !flag_emit_xref)
     {
-      tree value = DECL_INITIAL (node);
-      DECL_INITIAL (node) = NULL_TREE;
-      value = fold_constant_for_init (value, node);
-      DECL_INITIAL (node) = value;
+      tree value = fold_constant_for_init (node, node);
       if (value != NULL_TREE)
-       {
-         /* fold_constant_for_init sometimes widens the original type
-             of the constant (i.e. byte to int). It's not desirable,
-             especially if NODE is a function argument. */
-         if ((TREE_CODE (value) == INTEGER_CST
-              || TREE_CODE (value) == REAL_CST)
-             && TREE_TYPE (node) != TREE_TYPE (value))
-           return convert (TREE_TYPE (node), value);
-         else
-           return value;
-       }
+       return value;
     }
   return node;
 }
@@ -16010,8 +15997,10 @@ fold_constant_for_init (node, context)
 
   switch (code)
     {
-    case STRING_CST:
     case INTEGER_CST:
+      if (node == null_pointer_node)
+       return NULL_TREE;
+    case STRING_CST:
     case REAL_CST:
       return node;
 
@@ -16084,6 +16073,8 @@ fold_constant_for_init (node, context)
       /* Guard against infinite recursion. */
       DECL_INITIAL (node) = NULL_TREE;
       val = fold_constant_for_init (val, node);
+      if (val != NULL_TREE && TREE_CODE (val) != STRING_CST)
+       val = try_builtin_assignconv (NULL_TREE, TREE_TYPE (node), val);
       DECL_INITIAL (node) = val;
       return val;