From patchwork Tue Jan 31 17:23:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 138815 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 6DEA2B6F62 for ; Wed, 1 Feb 2012 04:23:43 +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=1328635424; h=Comment: DomainKey-Signature:Received: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=7vpnMfL rvqGrjo+WxcMbo6hzbMQ=; b=AZjE9wroVY4e/PzeMDtiIJ+yqx14Aw639r9TB2F noYLalcn5GmlwU772Zv6+bxiKUblvw59B7yJ1G4TvYmY/u3AgGAqavIJSOkgjFE/ b9zY/GxKqxIAQ1SQjtwvRnYBFhGYq2yNNdicLZbpnBJEUadF5eW9dVA1C4qY8NPI 8Ics= 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: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=I372Nw7ylExsYN7vatId+lzhsK4tXxgSWBphhZ6ixZL9i8NghoyQh4Iilshf5O 5b2yCnZgn60nkkfcsQafDLwoXQXMCJofmOTP3sP0JoZ5OIMl5f6+SmZO7vhz1kAc PvcHiZ06DHAMjWd1iInAp0LzxxGnCj6mIT2BRCeN/JcW8=; Received: (qmail 3524 invoked by alias); 31 Jan 2012 17:23:34 -0000 Received: (qmail 3512 invoked by uid 22791); 31 Jan 2012 17:23:30 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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, 31 Jan 2012 17:23: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 q0VHNCZN005028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 31 Jan 2012 12:23:12 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0VHNBP9000395 for ; Tue, 31 Jan 2012 12:23:11 -0500 Received: from [0.0.0.0] (ovpn-113-67.phx2.redhat.com [10.3.113.67]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0VHN9W0001588 for ; Tue, 31 Jan 2012 12:23:10 -0500 Message-ID: <4F28237C.3000902@redhat.com> Date: Tue, 31 Jan 2012 12:23:08 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/52043 (ICE with pack expansion) 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 The problem here is with tsubst_pack_expansion trying to decide whether or not to look at local_specializations. Previously we checked cp_unevaluated_context, but that was wrong because some uses in trailing-return-types have the pack expansion outside the decltype. Then we checked at_function_scope_p(), but that turns out not to be right either, because we might be in a different function, or have already discarded local_specializations. This patch fixes the check to use whether we were in a function when we parsed the expansion, which is more stable. Tested x86_64-pc-linux-gnu, applying to trunk. commit 480a0ab1c458357a701b7ae604b88c058b22d237 Author: Jason Merrill Date: Tue Jan 31 11:10:21 2012 -0500 PR c++/52043 * cp-tree.h (PACK_EXPANSION_LOCAL_P): New. * pt.c (make_pack_expansion, tsubst_initializer_list): Set it. (tsubst_pack_expansion): Check it. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f27755e..d435dbd 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -76,6 +76,7 @@ c-common.h, not after. TRANSACTION_EXPR_IS_STMT (in TRANSACTION_EXPR) CONVERT_EXPR_VBASE_PATH (in CONVERT_EXPR) OVL_ARG_DEPENDENT (in OVERLOAD) + PACK_EXPANSION_LOCAL_P (in *_PACK_EXPANSION) 1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE) TI_PENDING_TEMPLATE_FLAG. TEMPLATE_PARMS_FOR_INLINE. @@ -2839,6 +2840,9 @@ extern void decl_shadowed_for_var_insert (tree, tree); ? &TYPE_MAXVAL (NODE) \ : &TREE_OPERAND ((NODE), 2)) +/* True iff this pack expansion is within a function context. */ +#define PACK_EXPANSION_LOCAL_P(NODE) TREE_LANG_FLAG_0 (NODE) + /* Determine if this is an argument pack. */ #define ARGUMENT_PACK_P(NODE) \ (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK \ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ad2b4df..4c93b31 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3238,6 +3238,8 @@ make_pack_expansion (tree arg) } PACK_EXPANSION_PARAMETER_PACKS (result) = parameter_packs; + PACK_EXPANSION_LOCAL_P (result) = at_function_scope_p (); + return result; } @@ -9340,7 +9342,7 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, } if (TREE_CODE (parm_pack) == PARM_DECL) { - if (at_function_scope_p ()) + if (PACK_EXPANSION_LOCAL_P (t)) arg_pack = retrieve_local_specialization (parm_pack); else { @@ -18905,6 +18907,7 @@ tsubst_initializer_list (tree t, tree argvec) /* Build a dummy EXPR_PACK_EXPANSION that will be used to expand each argument in the TREE_VALUE of t. */ expr = make_node (EXPR_PACK_EXPANSION); + PACK_EXPANSION_LOCAL_P (expr) = true; PACK_EXPANSION_PARAMETER_PACKS (expr) = PACK_EXPANSION_PARAMETER_PACKS (TREE_PURPOSE (t)); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic122.C b/gcc/testsuite/g++.dg/cpp0x/variadic122.C new file mode 100644 index 0000000..6a1fb08 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic122.C @@ -0,0 +1,22 @@ +// PR c++/52043 +// { dg-options "-std=c++11 -Wreturn-type" } + +template < class T > struct Container +{ + T f (); +}; + +template < class T > +T deref (T) +{} // { dg-warning "no return" } + +template < class T, class ... Args > +auto deref (T u, int, Args ... args)->decltype (deref (u.f (), args ...)) +{} // { dg-warning "no return" } + +void +foo () +{ + Container < Container < int > > v; + deref (v, 2); +}