From patchwork Tue Jun 21 20:11:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 101360 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 4B8EEB6F84 for ; Wed, 22 Jun 2011 06:11:31 +1000 (EST) Received: (qmail 24269 invoked by alias); 21 Jun 2011 20:11:27 -0000 Received: (qmail 24257 invoked by uid 22791); 21 Jun 2011 20:11:24 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_RG, TW_SV, T_RP_MATCHES_RCVD 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; Tue, 21 Jun 2011 20:11:06 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5LKB5rH024185 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Jun 2011 16:11:05 -0400 Received: from [127.0.0.1] (ovpn-113-44.phx2.redhat.com [10.3.113.44]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5LKB5Ea008552 for ; Tue, 21 Jun 2011 16:11:05 -0400 Message-ID: <4E00FAD8.8040503@redhat.com> Date: Tue, 21 Jun 2011 16:11:04 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/49482 (bogus set but not used parameter warning with lambda) 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 When we are building up a call by hand at low level, apparently we need to explicitly mark the arguments as read. Or unset TREE_USED, I suppose, but they are in fact read. Tested x86_64-pc-linux-gnu, applied to trunk and 4.6.1. commit dec88b99a5f96603df3518da6b108e058613bc2d Author: jason Date: Tue Jun 21 20:07:45 2011 +0000 PR c++/49482 * semantics.c (maybe_add_lambda_conv_op): Call mark_exp_read for static fn parameters. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175273 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 594d239..6622de6 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8780,7 +8780,10 @@ maybe_add_lambda_conv_op (tree type) argvec = make_tree_vector (); VEC_quick_push (tree, argvec, arg); for (arg = DECL_ARGUMENTS (statfn); arg; arg = DECL_CHAIN (arg)) - VEC_safe_push (tree, gc, argvec, arg); + { + mark_exp_read (arg); + VEC_safe_push (tree, gc, argvec, arg); + } call = build_call_a (callop, VEC_length (tree, argvec), VEC_address (tree, argvec)); CALL_FROM_THUNK_P (call) = 1; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C new file mode 100644 index 0000000..77f35bc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C @@ -0,0 +1,12 @@ +// PR c++/49482 +// { dg-options "-std=c++0x -Wunused-but-set-parameter" } + +template +void f() { + []( bool b ){ return b; }; +} + +int main() +{ + f(); +}