Hi Nathan,

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?

thanks
Iain

gcc/testsuite/ChangeLog:

2020-04-14  Iain Sandoe  <i...@sandoe.co.uk>

        * g++.dg/cpp0x/lambda/pr94426-2.C: Add tests for Darwin’s codegen.

iff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/pr94426-2.C 
b/gcc/testsuite/g++.dg/cpp0x/lambda/pr94426-2.C
index 3db864c604b..fc85400388a 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/pr94426-2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/pr94426-2.C
@@ -16,5 +16,10 @@ 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* } } } } }
+
+// Darwin's assembler does not use .local (linker-visible symbols which are
+// not global are counted as local).
+// { dg-final { scan-assembler-not {.globl[ \t]+__Z3VARIZ1qvEUlvE_E} { target 
*-*-darwin* } } }
+// { dg-final { scan-assembler {.static_data[ \n\t]+__Z3VARIZ1qvEUlvE_E} { 
target *-*-darwin* } } }

Reply via email to