This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: namespace namespace
- From: Andrew Haley <aph at redhat dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Sam Ruby <rubys at intertwingly dot net>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Java Patch List <java-patches at gcc dot gnu dot org>
- Date: Tue, 07 Jul 2009 20:58:06 +0100
- Subject: Re: namespace namespace
- References: <4A3D95F1.6040803@intertwingly.net> <4A3E55E1.6010705@redhat.com> <4A403949.4090401@intertwingly.net> <4A40A09E.5040502@redhat.com> <9DAA724F-CC05-4A04-8B4D-386238D1D223@bluezoo.org> <7230133d0906230257j6b69373fj1709af1ee85d7bf8@mail.gmail.com> <4A40B4A1.8020007@intertwingly.net> <4A40CD50.3010904@redhat.com> <4A40DBB9.80703@intertwingly.net> <4A40E497.8090601@redhat.com> <4A4139C1.5060806@intertwingly.net> <4A41EF61.4060902@redhat.com> <4A421391.6020901@intertwingly.net> <4A48FC28.60608@redhat.com> <m3my7gbdqs.fsf@google.com>
Ian Lance Taylor wrote:
> Andrew Haley <aph@redhat.com> writes:
>
>> It turns out that the mangling of C++ keywords used by gcj is completely
>> broken:
>>
>> In particular, when a member name is a C++ keyword, "$" is appended to the
>> name. However, this is results in an illegal mangled name so it is not
>> possible to refer to the member from CNI code.
>>
>> Also, the set of C++ keywords in gjavah is different from the set in gcj.
>>
>> Also, types are not checked for C++ keywords, so javax.xml.namespace.* cannot
>> be referenced from CNI code.
>>
>> This patch fixes the problem.
>>
>> This is an ABI change. However, the ABI was almost completely broken
>> anyway.
>
> Does this require any changes to the demangler?
Good point. I suppose that for really pedantic accuracy there should be, yes.
> Note that the demangler currently has a special case for this:
>
> /* A Java mangled name may have a trailing '$' if it is a C++
> keyword. This '$' is not included in the length count. We just
> ignore the '$'. */
> if ((di->options & DMGL_JAVA) != 0
> && d_peek_char (di) == '$')
> d_advance (di, 1);
How interesting. I didn't know that.
I'm pretty sure that it can't possibly have worked, since there would have been
no way for CNI code to refer to methods or objects that had name components
that were C++ keywords. Unless, perhaps, there was a similar hack in the C++
compiler, but what would have been the point? Baffling.
Thanks,
Andrew.