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.

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)

-- 
Markus

Reply via email to