Hi Nathan,

Iain Sandoe <idsan...@googlemail.com> wrote:

> Nathan Sidwell <nat...@acm.org> wrote:
> 
>> My fix for 94147 was confusing no-linkage with internal linkage, at the 
>> language level.  That's wrong. (the std is confusing here, because it 
>> describes linkage of names (which is wrong), and lambdas have no names)
>> 
>> Lambdas with extra-scope, have linkage.  However, at the 
>> implementation-level that linkage is at least as restricted as the linkage 
>> of the extra-scope decl.
>> 
>> Further, when instantiating a variable initialized by a lambda, we must 
>> determine the visibility of the variable itself, before instantiating its 
>> initializer.  If the template arguments are internal (or no-linkage), the 
>> variable will have internal linkage, regardless of the linkage of the 
>> template it is instantiated from.  We need to know that before instantiating 
>> the lambda, so we can restrict its linkage correctly.
>> 
>> I'll commit this in a few days.
> 
> As discussed on irc,
> 
> The testcase for this fails on Darwin, where we don’t use .local or .comm for 
> the var.
> 
> I’ve tested this on x86-64-linux and darwin, 
> but I plan on testing on a few more Darwin boxen,
> OK to apply, if additional testing passes?

that testing revealed some differences in storage description for the variable 
(powerpc 32b darwin puts it in bss, like linux, but the remainer of the 
platform versions use .static_data).  However, that’s not the relevant 
observation.

the observation is that the storage and symbols for 

_Z3VARIZ1qvEUlvE_E

has not changed between gcc-9 and trunk.

What has changed is the function that initializes that variable:

_Z4InitIN3VARIZ1qvEUlvE_EUlvE_EEbT_

which was weak / comdat [Linux]  weak / global [Darwin] and now is text section 
local (which is what I understood was the intention of the change) .. so I 
wonder if the scan-asms are testing what you intended?

how about the following - where IMO, from the observation above, the first two 
tests are not especially useful and could be removed.

the remainder of the amendments cater for USER_LABEL_PREFIX and a different 
spelling for ‘weak’ in the Darwin assembly language.

So - this now tests that the symbol exists, is spelled the way you intend and 
is not weak (or global on Darwin).

WDYT?
Iain

diff --cc gcc/testsuite/g++.dg/cpp0x/lambda/pr94426-2.C
index 3db864c604b,3db864c604b..dd94ea1f325
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/pr94426-2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/pr94426-2.C
@@@ -16,5 -16,5 +16,11 @@@ void q (
  }
  
  // The instantiation of VAR becomes local
--// { dg-final { scan-assembler {.local        _Z3VARIZ1qvEUlvE_E} { target { 
i?86-*-* x86_64-*-* } } } }
--// { dg-final { scan-assembler {.comm _Z3VARIZ1qvEUlvE_E,1,1} { target { 
i?86-*-* x86_64-*-* } } } }
++// { dg-final { scan-assembler {.local        _Z3VARIZ1qvEUlvE_E} { target { 
{ i?86-*-* x86_64-*-* } && { ! *-*-darwin* } } } } }
++// { dg-final { scan-assembler {.comm _Z3VARIZ1qvEUlvE_E,1,1} { target { { 
i?86-*-* x86_64-*-* } && { ! *-*-darwin* } } } } }
++
++// The instantiation of VAR becomes local
++// { dg-final { scan-assembler-not {.globl[ 
\t]+_?_Z4InitIN3VARIZ1qvEUlvE_EUlvE_EEbT_} { target *-*-darwin* } } }
++// { dg-final { scan-assembler-not {.weak(_definition)?[ 
\t]+_?_Z4InitIN3VARIZ1qvEUlvE_EUlvE_EEbT_} { target  i?86-*-* x86_64-*-* 
*-*-darwin* } } }
++// Make sure it is defined with the mangling we expect.
++// { dg-final { scan-assembler {_?_Z4InitIN3VARIZ1qvEUlvE_EUlvE_EEbT_:} { 
target  i?86-*-* x86_64-*-* *-*-darwin* } } }

Reply via email to