From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C | 103 ++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C (limited to 'gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C') diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C new file mode 100644 index 000000000..5c9b483d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C @@ -0,0 +1,103 @@ +// Test lambda mangling +// { dg-require-weak "" } +// { dg-options "-std=c++0x -fno-inline" } + +template int algo(F fn) { return fn(); } +inline void g(int n) { + int bef(int i = []{ return 1; }()); + // Default arguments of block-extern function declarations + // remain in the context of the encloding function body. + // The closure type is encoded as Z1giEUlvE_. + // The call operator of that type is _ZZ1giENKUlvE_clEv. + +// { dg-final { scan-assembler "_ZZ1giENKUlvE_clEv" } } +// { dg-final { scan-assembler "weak\[^\n\r\]*_?_ZZ1giENKUlvE_clEv" { target { ! { *-*-darwin* *-*-mingw* *-*-cygwin } } } } } + + algo([=]{return n+bef();}); + // The captured entities do not participate in + // and so this closure type has the same as + // the previous one. It encoding is therefore Z1giEUlvE0_ + // and the call operator is _ZZ1giENKUlvE0_clEv. The + // instance of "algo" being called is then + // _Z4algoIZ1giEUlvE0_EiT_. + +// { dg-final { scan-assembler "_Z4algoIZ1giEUlvE0_EiT_" } } +// { dg-final { scan-assembler "_ZZ1giENKUlvE0_clEv" } } + + int i = []{return 1;}(); + +} + +struct S { + void f(int = + // Type: ZN1S1fEiiEd0_UlvE_ + // Operator: _ZZN1S1fEiiEd0_NKUlvE_clEv +// { dg-final { scan-assembler "_ZZN1S1fEiiEd0_NKUlvE_clEv" } } +// { dg-final { scan-assembler "weak\[^\n\r\]*_?_ZZN1S1fEiiEd0_NKUlvE_clEv" { target { ! { *-*-darwin* *-*-mingw* *-*-cygwin } } } } } + []{return 1;}() + // Type: ZN1S1fEiiEd0_UlvE0_ + // Operator: _ZZN1S1fEiiEd0_NKUlvE0_clEv +// { dg-final { scan-assembler "_ZZN1S1fEiiEd0_NKUlvE0_clEv" } } + + []{return 2;}(), + int = + // Type: ZN1S1fEiiEd_UlvE_ + // Operator: _ZZN1S1fEiiEd_NKUlvE_clEv +// { dg-final { scan-assembler "_ZZN1S1fEiiEd_NKUlvE_clEv" } } + []{return 3;}()); +}; + +template struct R { + static int x; +}; +template int R::x = []{return 1;}(); +template int R::x; +// Type of lambda in intializer of R::x: N1RIiE1xMUlvE_E +// Corresponding operator(): _ZNK1RIiE1xMUlvE_clEv +// { dg-final { scan-assembler "_ZNK1RIiE1xMUlvE_clEv" } } +// { dg-final { scan-assembler "weak\[^\n\r\]*_?_ZNK1RIiE1xMUlvE_clEv" { target { ! { *-*-mingw* *-*-cygwin } } } } } + +void bar() +{ + // lambdas in non-vague linkage functions have internal linkage. + // { dg-final { scan-assembler-not "weak\[^\n\r\]*bar\[^\n\r\]*Ul" } } + []{}(); +} + +// lambdas used in non-template, non-class body initializers are internal. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*_ZNKUlv" } } +// { dg-final { scan-assembler-not "weak\[^\n\r\]*variable" } } +int variable = []{return 1;}(); + +// And a template instantiated with such a lambda is also internal. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*algoIUl" } } +int var2 = algo([]{return 1;}); + +// As are lambdas used in non-class-body default arguments. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*function" } } +void function (int i = []{return 1;}()+[]{return 1;}()); + +struct Foo +{ + static int Int; + void Bar(int); +}; + +int Foo::Int = []{return 1;}(); +// Even default arguments for member functions that appear outside the +// class body are internal. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*Foo" } } +void Foo::Bar(int i = []{return 1;}()) {} + +// Even default arguments for function templates. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*fn2\[^\n\r\]*Ulv" } } +template +void fn2 (T t = []{return 1;}()) {} + +int main() +{ + g(42); + S().f(); + function(); + Foo().Bar(); + fn2(); +} -- cgit v1.2.3