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]

Java: Fix mangling of inner-class names, take 2


This patch removes special-casing of '$' from the name-mangling code in 
GCJ, which is required for inner class names to be compatible between 
Java and C++/CNI.

Why I think this is safe and the right thing to do:

1. There is no platform which libjava can build on that doesn't support 
'$' in labels, because other Java labels (eg "class$") have always used 
"$" without mangling it and there have been no reports of problems.

2. C++ already completely ignores NO_DOLLAR_IN_LABEL except for some 
cruft in the old name mangler, so it makes sense for Java to do the same.

3. If we ever want to build on a platform that cant deal with "$" in 
labels (unlikely), the mangling should really happen at a later stage in 
order to pick up other uses (such as the "class$") and be compatible 
between C++ and Java.

OK to commit?

regards

Bryce.

2001-12-20  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>

	* mangle.c (mangle_member_name): Don't special-case for 
	NO_DOLLAR_IN_LABEL.
	* mangle_name.c (unicode_mangling_length): Likewise.
	(append_unicode_mangled_name): Likewise.
	* parse.y (make_nested_class_name): Remove dead NO_DOLLAR_IN_LABEL
	code.

Index: mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/mangle.c,v
retrieving revision 1.20
diff -u -r1.20 mangle.c
--- mangle.c	2001/12/16 22:53:02	1.20
+++ mangle.c	2001/12/20 04:52:50
@@ -180,19 +180,9 @@
   append_gpp_mangled_name (IDENTIFIER_POINTER (name),
 			   IDENTIFIER_LENGTH (name));
 
-  /* If NAME happens to be a C++ keyword, add `$' or `.' or `_'. */
+  /* If NAME happens to be a C++ keyword, add `$'. */
   if (cxx_keyword_p (IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name)))
-    {
-#ifndef NO_DOLLAR_IN_LABEL
-      obstack_1grow (mangle_obstack, '$');
-#else  /* NO_DOLLAR_IN_LABEL */
-#ifndef NO_DOT_IN_LABEL
-      obstack_1grow (mangle_obstack, '.');
-#else  /* NO_DOT_IN_LABEL */
-      obstack_1grow (mangle_obstack, '_');
-#endif /* NO_DOT_IN_LABEL */
-#endif /* NO_DOLLAR_IN_LABEL */
-    }
+    obstack_1grow (mangle_obstack, '$');
 }
 
 /* Append the mangled name of TYPE onto OBSTACK.  */
Index: mangle_name.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/mangle_name.c,v
retrieving revision 1.3
diff -u -r1.3 mangle_name.c
--- mangle_name.c	2001/10/21 21:32:12	1.3
+++ mangle_name.c	2001/12/20 04:52:50
@@ -72,8 +72,7 @@
 /* Assuming (NAME, LEN) is a Utf8-encoded string, emit the string
    appropriately mangled (with Unicode escapes) to MANGLE_OBSTACK.
    Characters needing an escape are encoded `__UNN_' to `__UNNNN_', in
-   which case `__U' will be mangled `__U_'. `$' is mangled `$' or
-   __U24_ according to NO_DOLLAR_IN_LABEL.  */
+   which case `__U' will be mangled `__U_'.  */
 
 static void
 append_unicode_mangled_name (name, len)
@@ -87,11 +86,7 @@
     {
       int ch = UTF8_GET(ptr, limit);
 
-      if ((ISALNUM (ch) && ch != 'U')
-#ifndef NO_DOLLAR_IN_LABEL
-	  || ch == '$'
-#endif
-	  )
+      if ((ISALNUM (ch) && ch != 'U') || ch == '$')
 	obstack_1grow (mangle_obstack, ch);
       /* Everything else needs encoding */
       else
@@ -148,11 +143,7 @@
 
       if (ch < 0)
 	error ("internal error - invalid Utf8 name");
-      if ((ISALNUM (ch) && ch != 'U')
-#ifndef NO_DOLLAR_IN_LABEL
-	  || ch == '$'
-#endif
-	  )
+      if ((ISALNUM (ch) && ch != 'U') || ch == '$')
 	num_chars++;
       /* Everything else needs encoding */
       else
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.334
diff -u -r1.334 parse.y
--- parse.y	2001/12/17 19:14:07	1.334
+++ parse.y	2001/12/20 04:52:53
@@ -3511,12 +3511,6 @@
 	  TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
   obstack_grow (&temporary_obstack,
 		IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
-  /* Why is NO_DOLLAR_IN_LABEL defined? */
-#if 0
-#ifdef NO_DOLLAR_IN_LABEL
-  internal_error ("Can't use '$' as a separator for inner classes");
-#endif
-#endif
   obstack_1grow (&temporary_obstack, '$');
 }
 

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