From 669baa1576a1b90def048584f64dbe7cca3f0b94 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 27 May 2011 20:53:49 -0400 Subject: [PATCH] re PR c++/47049 ([C++0x] ICE in write_unnamed_type_name with lambda use) PR c++/47049 * semantics.c (maybe_add_lambda_conv_op): Fix COMDAT sharing. * decl.c (start_preparsed_function): Don't call comdat_linkage for a template. From-SVN: r174375 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 1 + gcc/cp/semantics.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ .../g++.dg/cpp0x/lambda/lambda-template2.C | 20 +++++++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9ccdee5a178..3419d518ffb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2011-05-27 Jason Merrill + PR c++/47049 + * semantics.c (maybe_add_lambda_conv_op): Fix COMDAT sharing. + * decl.c (start_preparsed_function): Don't call comdat_linkage for + a template. + PR c++/47132 * mangle.c (write_expression): Handle MODOP_EXPR. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3cc25bdbe33..8fe32592c5f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12672,6 +12672,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags) DECL_EXTERNAL (decl1) = 0; if (ctx != NULL_TREE && DECL_DECLARED_INLINE_P (ctx) + && !processing_template_decl && TREE_PUBLIC (ctx)) /* This is a function in a local class in an extern inline function. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 557bf4ce0b1..854bac7d6e9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8578,7 +8578,7 @@ maybe_add_lambda_conv_op (tree type) { /* Put the thunk in the same comdat group as the call op. */ struct cgraph_node *callop_node, *thunk_node; - DECL_COMDAT_GROUP (statfn) = DECL_COMDAT_GROUP (callop); + DECL_COMDAT_GROUP (statfn) = cxx_comdat_group (callop); callop_node = cgraph_get_create_node (callop); thunk_node = cgraph_get_create_node (statfn); gcc_assert (callop_node->same_comdat_group == NULL); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 915cd906aaa..36edc225434 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-05-27 Jason Merrill + + * g++.dg/cpp0x/lambda/lambda-template2.C: New. + 2011-05-27 Tobias Burnus PR fortran/18918 diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template2.C new file mode 100644 index 00000000000..12ffde724e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template2.C @@ -0,0 +1,20 @@ +// PR c++/47049 +// { dg-options -std=c++0x } + +enum { E = 0, F = 1 }; +template class S {}; +template +struct T +{ + static void + foo (S *p) + { + S u; + [&u] ()->bool {} (); + } +}; + +int main() +{ + T<0>().foo(0); +} -- 2.30.2