diff mbox

[C++] Fix PR77489 -- mangling of discriminator >= 10

Message ID 20170118153246.GE6668@x4
State New
Headers show

Commit Message

Markus Trippelsdorf Jan. 18, 2017, 3:32 p.m. UTC
On 2017.01.18 at 16:25 +0100, Jakub Jelinek wrote:
> On Wed, Jan 18, 2017 at 04:16:44PM +0100, Markus Trippelsdorf wrote:
> > No. It appears to work even without the additional condition:
> > 
> >  % g++ -fabi-version=10 -Wabi=11 -Wall -c gcc/testsuite/g++.dg/abi/pr77489.C
> > gcc/testsuite/g++.dg/abi/pr77489.C:56:16: warning: the mangled name of ‘localVar’ changes between -fabi-version=10 (_ZZ3foovE8localVar_11) and -fabi-version=11 (_ZZ3foovE8localVar__11_) [-Wabi]
> >      static int localVar = 12;
> >                 ^~~~~~~~
> > gcc/testsuite/g++.dg/abi/pr77489.C:52:16: warning: the mangled name of ‘localVar’ changes between -fabi-version=10 (_ZZ3foovE8localVar_10) and -fabi-version=11 (_ZZ3foovE8localVar__10_) [-Wabi]
> >      static int localVar = 11;
> >                 ^~~~~~~~
> 
> But it is less efficient then for the the one digit discriminators.
> When we set G.need_abi_warning unnecessarily, then mangle_decl has to
> mangle it again with different ABI flags and compare the two mangled
> identifiers.  If G.need_abi_warning is not set, we avoid that.

Ok, fair enough.

	PR c++/77489
	* mangle.c (write_discriminator): Reorganize abi warning check.

Comments

Jason Merrill Jan. 18, 2017, 3:43 p.m. UTC | #1
On Wed, Jan 18, 2017 at 10:32 AM, Markus Trippelsdorf
<markus@trippelsdorf.de> wrote:
> On 2017.01.18 at 16:25 +0100, Jakub Jelinek wrote:
>> On Wed, Jan 18, 2017 at 04:16:44PM +0100, Markus Trippelsdorf wrote:
>> > No. It appears to work even without the additional condition:
>> >
>> >  % g++ -fabi-version=10 -Wabi=11 -Wall -c gcc/testsuite/g++.dg/abi/pr77489.C
>> > gcc/testsuite/g++.dg/abi/pr77489.C:56:16: warning: the mangled name of ‘localVar’ changes between -fabi-version=10 (_ZZ3foovE8localVar_11) and -fabi-version=11 (_ZZ3foovE8localVar__11_) [-Wabi]
>> >      static int localVar = 12;
>> >                 ^~~~~~~~
>> > gcc/testsuite/g++.dg/abi/pr77489.C:52:16: warning: the mangled name of ‘localVar’ changes between -fabi-version=10 (_ZZ3foovE8localVar_10) and -fabi-version=11 (_ZZ3foovE8localVar__10_) [-Wabi]
>> >      static int localVar = 11;
>> >                 ^~~~~~~~
>>
>> But it is less efficient then for the the one digit discriminators.
>> When we set G.need_abi_warning unnecessarily, then mangle_decl has to
>> mangle it again with different ABI flags and compare the two mangled
>> identifiers.  If G.need_abi_warning is not set, we avoid that.
>
> Ok, fair enough.
>
>         PR c++/77489
>         * mangle.c (write_discriminator): Reorganize abi warning check.

OK, thanks.

Jason
diff mbox

Patch

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index d1b107cbb1d..31b0f543f31 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -1966,11 +1966,12 @@  write_discriminator (const int discriminator)
   if (discriminator > 0)
     {
       write_char ('_');
-      if (abi_version_at_least (11) && discriminator - 1 >= 10)
+      if (discriminator - 1 >= 10)
 	{
-	  write_char ('_');
 	  if (abi_warn_or_compat_version_crosses (11))
 	    G.need_abi_warning = 1;
+	  if (abi_version_at_least (11))
+	    write_char ('_');
 	}
       write_unsigned_number (discriminator - 1);
       if (abi_version_at_least (11) && discriminator - 1 >= 10)