From 568aac9cf7c95ef4102838d126decf016d98ea46 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 13 Dec 2000 22:36:24 +0000 Subject: [PATCH] parse.y (java_complete_lhs): Only allow compound assignment of reference type if type is String. * parse.y (java_complete_lhs): Only allow compound assignment of reference type if type is String. Co-Authored-By: Alexandre Petit-Bianco From-SVN: r38236 --- gcc/java/ChangeLog | 6 ++++++ gcc/java/parse.y | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index d28b5137232..5ed93c765e1 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2000-11-20 Tom Tromey + Alexandre Petit-Bianco + + * parse.y (java_complete_lhs): Only allow compound assignment of + reference type if type is String. + 2000-12-09 Alexandre Petit-Bianco * Make-lang.in (java/jcf-path.o:): libgcj.jar replaces libgcj.zip. diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 9283e575d71..7761130b14c 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -11608,6 +11608,14 @@ java_complete_lhs (node) nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), TREE_TYPE (lvalue), nn)); + /* If the assignment is compound and has reference type, + then ensure the LHS has type String and nothing else. */ + if (JREFERENCE_TYPE_P (TREE_TYPE (lvalue)) + && ! JSTRING_TYPE_P (TREE_TYPE (lvalue))) + parse_error_context (wfl_op2, + "Incompatible type for `+='. Can't convert `%s' to `java.lang.String'", + lang_printable_name (TREE_TYPE (lvalue), 0)); + /* 15.25.2.b: Left hand is an array access. FIXME */ } -- 2.30.2