diff options
author | Alexandre Petit-Bianco <apbianco@redhat.com> | 2001-09-07 11:30:29 -0700 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2001-09-07 11:30:29 -0700 |
commit | 731866ba53c49d2633c2d298a71462dbbd7f356b (patch) | |
tree | 8098278e0ae77ece871e4167b796a3e9826f8024 /gcc/java | |
parent | 9b3bd4249d2e0e46d4bec0909e626543bbd14d3b (diff) | |
download | gcc-731866ba53c49d2633c2d298a71462dbbd7f356b.zip gcc-731866ba53c49d2633c2d298a71462dbbd7f356b.tar.gz gcc-731866ba53c49d2633c2d298a71462dbbd7f356b.tar.bz2 |
re PR java/4230 (gcj -C segfaults on static string continuation '+' in gcj 3.1 expermental.)
2001-09-05 Alexandre Petit-Bianco <apbianco@redhat.com>
* jcf-write.c (generate_classfile): Issue an error in case of
field/initial value mismatch.
* parse.y (analyze_clinit_body): Keep <clinit> if an array is
being initialized and we're generating bytecode.
(java_complete_lhs): In MODIFY_EXPR section: added comments,
set DECL_INITIAL properly when appropriate.
Fixes PR java/4230
Fixes PR java/4204
(http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00247.html )
From-SVN: r45474
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/java/jcf-write.c | 4 | ||||
-rw-r--r-- | gcc/java/parse.y | 35 |
3 files changed, 46 insertions, 4 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index c508587..a33de53 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -17,6 +17,17 @@ resource files. * gcj.texi (Code Generation): Add documentation for -R flag. +2001-09-05 Alexandre Petit-Bianco <apbianco@redhat.com> + + * jcf-write.c (generate_classfile): Issue an error in case of + field/initial value mismatch. + * parse.y (analyze_clinit_body): Keep <clinit> if an array is + being initialized and we're generating bytecode. + (java_complete_lhs): In MODIFY_EXPR section: added comments, + set DECL_INITIAL properly when appropriate. + Fixes PR java/4230 + Fixes PR java/4204 + 2001-09-01 Per Bothner <per@bothner.com> * parse.y (maybe_yank_clinit): A field without an initializer is not diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 026ceb5..44c676f 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -2899,8 +2899,8 @@ generate_classfile (clas, state) { tree init = DECL_INITIAL (part); static tree ConstantValue_node = NULL_TREE; - // This conversion is a work-around for front-end bug. - init = convert (TREE_TYPE (part), init); + if (TREE_TYPE (part) != TREE_TYPE (init)) + fatal_error ("field initializer type mismatch."); ptr = append_chunk (NULL, 8, state); if (ConstantValue_node == NULL_TREE) ConstantValue_node = get_identifier ("ConstantValue"); diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 698f4227..0c544fb 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -7813,6 +7813,11 @@ analyze_clinit_body (bbody) break; case MODIFY_EXPR: + /* If we're generating to class file and we're dealing with an + array initialization, we return 1 to keep <clinit> */ + if (TREE_CODE (TREE_OPERAND (bbody, 1)) == NEW_ARRAY_INIT + && flag_emit_class_files) + return 1; /* Return 0 if the operand is constant, 1 otherwise. */ return ! TREE_CONSTANT (TREE_OPERAND (bbody, 1)); @@ -11898,16 +11903,31 @@ java_complete_lhs (node) value = fold_constant_for_init (nn, nn); + /* When we have a primitype type, or a string and we're not + emitting a class file, we actually don't want to generate + anything for the assignment. */ if (value != NULL_TREE && (JPRIMITIVE_TYPE_P (TREE_TYPE (value)) || (TREE_TYPE (value) == string_ptr_type_node && ! flag_emit_class_files))) { + /* Prepare node for patch_assignment */ TREE_OPERAND (node, 1) = value; + /* Call patch assignment to verify the assignment */ if (patch_assignment (node, wfl_op1, value) == error_mark_node) return error_mark_node; + /* Set DECL_INITIAL properly (a conversion might have + been decided by patch_assignment) and return the + empty statement. */ else - return empty_stmt_node; + { + tree patched = patch_string (TREE_OPERAND (node, 1)); + if (patched) + DECL_INITIAL (nn) = patched; + else + DECL_INITIAL (nn) = TREE_OPERAND (node, 1); + return empty_stmt_node; + } } if (! flag_emit_class_files) DECL_INITIAL (nn) = NULL_TREE; @@ -11999,7 +12019,18 @@ java_complete_lhs (node) || JSTRING_P (TREE_TYPE (node)))) node = java_refold (node); } - + + /* Seek to set DECL_INITIAL to a proper value, since it might have + undergone a conversion in patch_assignment. We do that only when + it's necessary to have DECL_INITIAL properly set. */ + nn = TREE_OPERAND (node, 0); + if (TREE_CODE (nn) == VAR_DECL + && DECL_INITIAL (nn) && CONSTANT_VALUE_P (DECL_INITIAL (nn)) + && FIELD_STATIC (nn) && FIELD_FINAL (nn) + && (JPRIMITIVE_TYPE_P (TREE_TYPE (nn)) + || TREE_TYPE (nn) == string_ptr_type_node)) + DECL_INITIAL (nn) = TREE_OPERAND (node, 1); + CAN_COMPLETE_NORMALLY (node) = 1; return node; |