From patchwork Wed Feb 13 18:12:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 220223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8671F2C0294 for ; Thu, 14 Feb 2013 05:12:24 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1361383944; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=vTAjI8o KnpTQV+tzx59VUGvOZ20=; b=mErUbl54/f4qxGp9uzhH+Wx122ekhoJYtQEGchs moOuf6pVcWogfx5TAAbyKMA9J6uM+Wfe5p0TdAlSP0d9htnxsyU39QU307OkRUd+ oZIfbyv4of7Uez4qh6jEtPGx3jzd2ooPMzm8rnAuICl4y/loml23xcEjZafVCgqh 37U8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=iBmp7ZP3iKrxVGohtoqP9Pf6jhiCpsR0/A1Q0Llzl1K0BGzyU8U42zH77C2b1D GxXHcg4gX+MEs7Z0JZrCHf5YsdZeq2EE7rVnYj5UtLQakcHOKKL6iupM7R4KegK1 ArXUNb+Sft2zAnWRk1nQtRrH/G37fn5q8P7xvNCt9qZSA=; Received: (qmail 2469 invoked by alias); 13 Feb 2013 18:12:19 -0000 Received: (qmail 2459 invoked by uid 22791); 13 Feb 2013 18:12:17 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Feb 2013 18:12:12 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1DICBuQ016443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 13 Feb 2013 13:12:11 -0500 Received: from [10.3.113.24] (ovpn-113-24.phx2.redhat.com [10.3.113.24]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1DIC9vU027183 for ; Wed, 13 Feb 2013 13:12:10 -0500 Message-ID: <511BD779.2090404@redhat.com> Date: Wed, 13 Feb 2013 13:12:09 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Thunderbird/21.0a1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/55720 (link error with lambda conversion) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Most of the G++ linkage code really needs to be torn out in favor of just using cgraph. Until that happens, we need to set TREE_USED here so that decl_needed_p will return true and allow cgraph to consider the function. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit 701e03d86ffb5c36e1c907e84b8b0dc504ebe5b2 Author: Jason Merrill Date: Wed Feb 13 12:52:51 2013 -0500 PR c++/55720 * semantics.c (maybe_add_lambda_conv_op): Mark static thunk TREE_USED. 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..861c91c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv7.C @@ -0,0 +1,20 @@ +// PR c++/55720 +// { 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()(); +}