aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2002-09-11 19:53:14 +0000
committerTom Tromey <tromey@redhat.com>2002-09-11 19:53:14 +0000
commit6a4de672650edf50b61819856f0a7388393b3ad2 (patch)
treee28d832f590eaf7db9f11637f405d577093281fc /gcc/java
parent56b79689f877cbfebbdb7f26bb3299aa53604e3c (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@57036 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog8
-rw-r--r--gcc/java/parse.y23
2 files changed, 15 insertions, 16 deletions
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 <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:
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;