This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: RFA: fix PR


This fixes PR java/16675.

We represent `null' using null_pointer_node, which has type `void*'.
When creating an anonymous class constructor, we don't look for this,
and we end up creating a constructor with an argument of that type.
Then the name mangler crashes when trying to mangle this (which makes
sense in a way as this is not a valid java type).

This patch fixes the bug in the simplest way, by adding a check for
null_pointer_node when creating the anonymous constructor.  (We can't
do the check in the caller as that will cause problems when calling an
ordinary constructor with a `null' argument.)

Test case included.  Ok?

Tom

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	PR java/16675:
	* parse.y (craft_constructor): Special case null_pointer_node.

Index: gcc/java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.523
diff -u -r1.523 parse.y
--- gcc/java/parse.y 26 Nov 2004 18:04:45 -0000 1.523
+++ gcc/java/parse.y 2 Dec 2004 18:19:47 -0000
@@ -5591,6 +5591,10 @@
   /* Then if there are any args to be enforced, enforce them now */
   for (; args && args != end_params_node; args = TREE_CHAIN (args))
     {
+      /* If we see a `void *', we need to change it to Object.  */
+      if (TREE_VALUE (args) == TREE_TYPE (null_pointer_node))
+	TREE_VALUE (args) = object_ptr_type_node;
+
       sprintf (buffer, "parm%d", i++);
       parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
     }
Index: libjava/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	For PR java/16675:
	* testsuite/libjava.compile/PR16675.java: New file.

Index: libjava/testsuite/libjava.compile/PR16675.java
===================================================================
RCS file: libjava/testsuite/libjava.compile/PR16675.java
diff -N libjava/testsuite/libjava.compile/PR16675.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.compile/PR16675.java 2 Dec 2004 18:19:52 -0000
@@ -0,0 +1,13 @@
+public class PR16675 {
+    public PR16675(Object obj) { }
+
+    public void someTestMethod() {
+        // gcj crashed compiling this, as `null' had type `void*'.
+        new PR16675(null) { };
+    }
+
+    public void someTestMethod2() {
+        new PR16675((Object) null) { };
+    }
+
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]