From: Per Bothner Date: Wed, 11 Sep 2002 19:53:14 +0000 (-0700) Subject: parse.y (fold_constant_for_init): If a VAR_DECL, convert numerical constant to the... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6e471ea7b847f2a8bf4ee0673dc64a4156ec694e;p=gcc.git parse.y (fold_constant_for_init): If a VAR_DECL, convert numerical constant to the type of the field. 2002-09-11 Per Bothner * 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 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 63d036a53e4..2defb3301aa 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,11 @@ +2002-09-11 Per Bothner + + * 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 For PR java/5794: diff --git a/gcc/java/parse.y b/gcc/java/parse.y index aa593f9f072..2112b717da0 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -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;