PATCH: bug fix for Java string concatenation

Tom Tromey tromey@cygnus.com
Fri Jan 29 15:12:00 GMT 1999


I'm committing the appended patch.  It fixes a bug in string
concatenation where one of the arguments was a char[].

1999-01-29  Tom Tromey  <tromey@cygnus.com>

	* parse.h (BUILD_APPEND): If ARG is a non-String object reference,
	then cast it to Object before calling `append' method.

Tom

Index: parse.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/java/parse.h,v
retrieving revision 1.33.2.12
diff -u -r1.33.2.12 parse.h
--- parse.h	1999/01/13 12:00:57	1.33.2.12
+++ parse.h	1999/01/29 20:32:35
@@ -498,9 +498,16 @@
 #define COMPLETE_CHECK_OP_2(NODE) COMPLETE_CHECK_OP(NODE, 2)
 
 /* Building invocations: append(ARG) and StringBuffer(ARG) */
-#define BUILD_APPEND(ARG)						     \
-  build_method_invocation (wfl_append, 					     \
-			   (ARG ? build_tree_list (NULL, (ARG)): NULL_TREE))
+#define BUILD_APPEND(ARG)						      \
+  ((JSTRING_TYPE_P (TREE_TYPE (ARG)) || JPRIMITIVE_TYPE_P (TREE_TYPE (ARG)))  \
+   ? build_method_invocation (wfl_append,                                     \
+			      ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE)\
+   : build_method_invocation (wfl_append,                                     \
+			      ARG ? build_tree_list (NULL,                    \
+						     build1 (CONVERT_EXPR,    \
+							     object_type_node,\
+							     (ARG)))          \
+			      : NULL_TREE))
 #define BUILD_STRING_BUFFER(ARG)					      \
   build_new_invocation (wfl_string_buffer, 				      \
 			(ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))



More information about the Gcc-patches mailing list