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 Re: mangling of '$' / DOLLARS_IN_IDENTIFIERS cleanup


Adam Megacz wrote:

>Hi, all. I recently attempted to link code compiled with g++ to code
>compiled with gcj. Unfortunately, the link fails because, according to
>Bryce McKinlay (who was kind enough to let me quote this):
>
>>Its because gcj and g++ disagree on how the "$" symbol should be 
>>mangled. IIRC, the C++ guys agreed that it should do what gcj does 
>>(mangle it to a unicode symbol), but they never implemented it.
>>
> 
>[as discussed in http://gcc.gnu.org/ml/gcc-patches/2001-03/msg01667.html]
>

On second thought, given that we use '$' as in "Foo.class$" anyway, 
there doesn't seem to be any reason why Java shouldn't use it for the 
nested class namespace separator too. The problem seems to stem from 
Java assuming that NO_DOLLAR_IN_LABEL meant that the target didn't 
support dollars in labels, which isn't actually the case. Rather, this 
patch changes it to assume a target will set DOLLARS_IN_IDENTIFIERS to 0 
if it really doesn't support '$' in identifiers.

OK to commit?

Bryce.




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

	* defaults.h: Define DOLLARS_IN_IDENTIFIERS if not defined by target.
	* c-decl.c: Don't define DOLLARS_IN_IDENTIFIERS here.
cp:
	* decl2.c: Don't define DOLLARS_IN_IDENTIFIERS here.
java:
	* parse.y (make_nested_class_name): Remove dead NO_DOLLAR_IN_LABEL
	check.
	* mangle_name.c (append_unicode_mangled_name): Permit '$' in 
	identifiers unless DOLLARS_IN_IDENTIFIERS is 0.
	(unicode_mangling_length): Likewise.
	
Index: defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.61
diff -u -r1.61 defaults.h
--- defaults.h	2001/12/02 14:38:06	1.61
+++ defaults.h	2001/12/05 02:36:00
@@ -457,4 +457,9 @@
 #define PREFERRED_DEBUGGING_TYPE NO_DEBUG
 #endif
 
+/* Nonzero means `$' can be in an identifier.  */
+#ifndef DOLLARS_IN_IDENTIFIERS
+#define DOLLARS_IN_IDENTIFIERS 1
+#endif
+
 #endif  /* ! GCC_DEFAULTS_H */
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.278
diff -u -r1.278 c-decl.c
--- c-decl.c	2001/12/04 22:55:37	1.278
+++ c-decl.c	2001/12/05 02:36:01
@@ -436,9 +436,6 @@
 
 /* Nonzero means `$' can be in an identifier.  */
 
-#ifndef DOLLARS_IN_IDENTIFIERS
-#define DOLLARS_IN_IDENTIFIERS 1
-#endif
 int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
 
 /* Decode the string P as a language-specific option for C.
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.501
diff -u -r1.501 decl2.c
--- decl2.c	2001/11/30 03:14:56	1.501
+++ decl2.c	2001/12/05 02:36:01
@@ -308,9 +308,6 @@
 
 /* Nonzero means `$' can be in an identifier.  */
 
-#ifndef DOLLARS_IN_IDENTIFIERS
-#define DOLLARS_IN_IDENTIFIERS 1
-#endif
 int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
 
 /* Nonzero means allow Microsoft extensions without a pedwarn.  */
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.330
diff -u -r1.330 parse.y
--- parse.y	2001/12/04 19:30:13	1.330
+++ parse.y	2001/12/05 02:36:02
@@ -3513,12 +3513,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: java/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/05 02:36:02
@@ -73,7 +73,7 @@
    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.  */
+   __U24_ according to DOLLARS_IN_IDENTIFIERS.  */
 
 static void
 append_unicode_mangled_name (name, len)
@@ -88,10 +88,7 @@
       int ch = UTF8_GET(ptr, limit);
 
       if ((ISALNUM (ch) && ch != 'U')
-#ifndef NO_DOLLAR_IN_LABEL
-	  || ch == '$'
-#endif
-	  )
+	  || (DOLLARS_IN_IDENTIFIERS && ch == '$'))
 	obstack_1grow (mangle_obstack, ch);
       /* Everything else needs encoding */
       else
@@ -149,10 +146,7 @@
       if (ch < 0)
 	error ("internal error - invalid Utf8 name");
       if ((ISALNUM (ch) && ch != 'U')
-#ifndef NO_DOLLAR_IN_LABEL
-	  || ch == '$'
-#endif
-	  )
+	  || (DOLLARS_IN_IDENTIFIERS && ch == '$'))
 	num_chars++;
       /* Everything else needs encoding */
       else

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