From patchwork Fri Dec 23 21:58:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 133144 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 6E45DB71E9 for ; Sat, 24 Dec 2011 08:58:54 +1100 (EST) Received: (qmail 1365 invoked by alias); 23 Dec 2011 21:58:52 -0000 Received: (qmail 1351 invoked by uid 22791); 23 Dec 2011 21:58:51 -0000 X-SWARE-Spam-Status: No, hits=-7.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_FN 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; Fri, 23 Dec 2011 21:58:35 +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 pBNLwZAm028349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 23 Dec 2011 16:58:35 -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 pBNLwZ5w027232 for ; Fri, 23 Dec 2011 16:58:35 -0500 Received: from [0.0.0.0] ([10.3.113.3]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pBNLwX8D006341 for ; Fri, 23 Dec 2011 16:58:34 -0500 Message-ID: <4EF4F989.6090207@redhat.com> Date: Fri, 23 Dec 2011 16:58:33 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111112 Thunderbird/8.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51507 (pack expansion in trailing-return-type) 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 existing code to handle pack expansions in trailing-return-type assumed that such expansions would only occur inside decltype, which is not the case. This patch fixes the test to check for whether or not we're doing the substitution in the context of a function body, and fixes at_function_scope_p to properly return false when we're substituting deduced arguments into a candidate function template. Even with the change to at_function_scope_p it was impossible to tell that we weren't in function scope when instantiating a function declaration as part of overload resolution, so I also changed instantiate_template_1 to use push_to_top_level rather than just clear processing_template_decl. In my testing it was enough to just clear current_function_decl as well, but since in fact the instantiation happens at top level it seems more correct to use push_to_top_level. The second patch is a bug I noticed in dependent_name while working on this patch, though it isn't necessary to this patch; a BASELINK should not be considered a dependent name, or we end up treating calls to members of different classes as equivalent. Tested x86_64-pc-linux-gnu, applying to trunk. commit a02c1be6a5cb39703b715e8b490976e8eacc9431 Author: Jason Merrill Date: Fri Dec 23 13:58:46 2011 -0500 * tree.c (dependent_name): OFFSET_REF and BASELINK are not dependent names. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 634c267..dea7632 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1463,6 +1463,8 @@ dependent_name (tree x) if (TREE_CODE (x) == IDENTIFIER_NODE) return x; if (TREE_CODE (x) != COMPONENT_REF + && TREE_CODE (x) != OFFSET_REF + && TREE_CODE (x) != BASELINK && is_overloaded_fn (x)) return DECL_NAME (get_first_fn (x)); return NULL_TREE;