aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-02-13 13:17:39 -0500
committerJason Merrill <jason@gcc.gnu.org>2013-02-13 13:17:39 -0500
commit43c2d791b4380088012fe812a8be156e0f593ee5 (patch)
tree5451de9306c729da082d70e09debb785aa97a0cf
parent70fc7c6c3dff619348c917b619bf52ac78a6ced1 (diff)
downloadgcc-43c2d791b4380088012fe812a8be156e0f593ee5.zip
gcc-43c2d791b4380088012fe812a8be156e0f593ee5.tar.gz
gcc-43c2d791b4380088012fe812a8be156e0f593ee5.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/semantics.c2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv7.C20
3 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ec1e7f2..7cb0653 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2013-02-13 Jason Merrill <jason@redhat.com>
+ 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 46c2e64..95158a5 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 0000000..89e4e4b
--- /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 <class T>
+struct X {
+ static void (*code) ();
+};
+
+template <class T>
+void (*X<T>::code) () = []{}; // Line 7
+
+struct Y {
+ void (*code) () = []{} ; // Line 10
+ void operator()() { code(); }
+};
+
+int main () {
+ X<int>::code();
+ Y()();
+}