From: Nathan Sidwell Date: Mon, 25 Mar 2019 12:22:47 +0000 (+0000) Subject: [C++] compiler incompatibility with lambdas X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d03f6e7bf321767f80c8474fb5aa8c60226bf445;p=gcc.git [C++] compiler incompatibility with lambdas https://gcc.gnu.org/ml/gcc-patches/2019-03/msg00982.html * lambda.c (maybe_add_lambda_conv_op): Don't add to comdat group. * g++.dg/abi/lambda-static-1.C: New. From-SVN: r269915 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 16f1b8e1aae..7589b30e852 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2019-03-25 Nathan Sidwell + + * lambda.c (maybe_add_lambda_conv_op): Don't add to comdat group. + 2019-03-22 Jakub Jelinek PR c++/60702 diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 3e176760ba5..93664181b47 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -1252,12 +1252,6 @@ maybe_add_lambda_conv_op (tree type) start_preparsed_function (statfn, NULL_TREE, SF_PRE_PARSED | SF_INCLASS_INLINE); - if (DECL_ONE_ONLY (statfn)) - { - /* Put the thunk in the same comdat group as the call op. */ - cgraph_node::get_create (statfn)->add_to_same_comdat_group - (cgraph_node::get_create (callop)); - } tree body = begin_function_body (); tree compound_stmt = begin_compound_stmt (0); if (!generic_lambda_p) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ef7ae1b1c4c..5aead43f147 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-03-25 Nathan Sidwell + + * g++.dg/abi/lambda-static-1.C: New. + 2019-03-25 Richard Biener PR tree-optimization/89802 diff --git a/gcc/testsuite/g++.dg/abi/lambda-static-1.C b/gcc/testsuite/g++.dg/abi/lambda-static-1.C new file mode 100644 index 00000000000..3d23ddc4007 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/lambda-static-1.C @@ -0,0 +1,25 @@ +// { dg-do compile { target { c++14 && comdat_group } } } +// { dg-additional-options -fno-inline } + +inline auto lamby () +{ + return [] {}; +} + +void direct () +{ + lamby ()(); +} + +void indirect () +{ + void (*invoke) () = lamby (); + + invoke (); +} + +// The call operator and the static invoker should be comdat, but not +// the same group. (that would be a compiler incompatibility) + +// { dg-final { scan-assembler ".section\[\t ]*.text._ZZ5lambyvENKUlvE_clEv,\[^\n\r]*,_ZZ5lambyvENKUlvE_clEv,comdat" } } +// { dg-final { scan-assembler ".section\[\t ]*.text._ZZ5lambyvENUlvE_4_FUNEv,\[^\n\r]*,_ZZ5lambyvENUlvE_4_FUNEv,comdat" } }