From: Jason Merrill Date: Wed, 13 Feb 2013 18:17:39 +0000 (-0500) Subject: re PR c++/55710 ([C++11] Linkage errors with lambdas) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43c2d791b4380088012fe812a8be156e0f593ee5;p=gcc.git re PR c++/55710 ([C++11] Linkage errors with lambdas) PR c++/55710 * semantics.c (maybe_add_lambda_conv_op): Mark static thunk TREE_USED. From-SVN: r196025 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ec1e7f20628..7cb0653cea1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-02-13 Jason Merrill + PR c++/55710 + * semantics.c (maybe_add_lambda_conv_op): Mark static thunk + TREE_USED. + PR c++/55879 * semantics.c (cxx_bind_parameters_in_call): Undo DECL_BY_REFERENCE. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 46c2e643806..95158a58771 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9559,6 +9559,8 @@ maybe_add_lambda_conv_op (tree type) body = begin_function_body (); compound_stmt = begin_compound_stmt (0); + /* decl_needed_p needs to see that it's used. */ + TREE_USED (statfn) = 1; finish_return_stmt (decay_conversion (statfn, tf_warning_or_error)); finish_compound_stmt (compound_stmt); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv7.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv7.C new file mode 100644 index 00000000000..89e4e4babf5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv7.C @@ -0,0 +1,20 @@ +// PR c++/55710 +// { dg-do link { target c++11 } } + +template +struct X { + static void (*code) (); +}; + +template +void (*X::code) () = []{}; // Line 7 + +struct Y { + void (*code) () = []{} ; // Line 10 + void operator()() { code(); } +}; + +int main () { + X::code(); + Y()(); +}