From patchwork Wed May 28 17:06:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 353533 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E4E1C14009A for ; Thu, 29 May 2014 03:09:24 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=HSzat77t83jM4XWOo XRK6fKx+XFzboxz+l0XICgcLNKLALUEWj6jhRm5jlRRfl4SD9Z3VxIPLU7ncAxfM Sy19HO9hCgP+qy65UQ0CY3kOyc/22+2UWLvDPtBPKDVnJpXYOArxHvz4XkMkOYnb WiLWaoK33TZRb8gKrKvhe/gGIQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=ZQQe4OdKCHKCpMeGEEpVX7X uojU=; b=tjhJ8w1VLqYAAZ0rEK3CvzFZGmwROmIzZjfjVYPoY5cRnLS77BzXjNW kaolvsO9dt2qkLdVACXa4DvprkdAc4dFxQl583HbyVYJbE4C9xCARjcZW5d0C/oK iAdt4bSFNKpiVF0agORAI5iO+cy2G8g5N+wI2Azcib4bdR6zrriY= Received: (qmail 24906 invoked by alias); 28 May 2014 17:09:15 -0000 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 Received: (qmail 24888 invoked by uid 89); 28 May 2014 17:09:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 28 May 2014 17:09:10 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4SH98ct003975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 May 2014 17:09:08 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4SH97d5002903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 May 2014 17:09:08 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4SH97r8024431; Wed, 28 May 2014 17:09:07 GMT Received: from [192.168.1.4] (/79.33.215.223) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 May 2014 10:09:07 -0700 Message-ID: <53861796.7070309@oracle.com> Date: Wed, 28 May 2014 19:06:30 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 57543 References: <5384935D.5020406@oracle.com> <5384C817.9010004@redhat.com> <5385064C.9020203@oracle.com> <53850C1F.7020902@oracle.com> <5385B756.8070707@oracle.com> <5385FD69.6020000@redhat.com> <538602EF.9060605@oracle.com> <53860589.5040106@redhat.com> <538607DF.8060702@oracle.com> <53860FE6.8050207@redhat.com> In-Reply-To: <53860FE6.8050207@redhat.com> X-IsSubscribed: yes Hi, On 05/28/2014 06:33 PM, Jason Merrill wrote: > On 05/28/2014 11:59 AM, Paolo Carlini wrote: >> I see. Even not considering this issue, there are many regression if I >> inject for all method types. I'm afraid the issue turns out to be much >> more tricky than I hoped, I guess I'm going to unassign myself, for now, >> and work on some other pending issues in my todo. You are of course more >> than welcome to take it and include my additional tests in your work! > > OK. Please add a link to this thread in the PR, if you haven't already. Now, I got this "insane" idea: would it make sense to simply invert the substitutions (args and return) unconditionally? I'm asking because the below appears to pass the testsuite modulo decltype28.C which we would end up accepting, but likewise do current clang, icc, and Solaris Studio!?! (In case I would have also to double check something weird I was seeing if the injection happens for all method types...) Thanks! Paolo. /////////////////////// Index: cp/pt.c =================================================================== --- cp/pt.c (revision 211024) +++ cp/pt.c (working copy) @@ -11322,8 +11322,32 @@ tsubst_function_type (tree t, /* The TYPE_CONTEXT is not used for function/method types. */ gcc_assert (TYPE_CONTEXT (t) == NULL_TREE); + /* Substitute the argument types. */ + arg_types = tsubst_arg_types (TYPE_ARG_TYPES (t), args, NULL_TREE, + complain, in_decl); + if (arg_types == error_mark_node) + return error_mark_node; + /* Substitute the return type. */ + tree save_ccp = current_class_ptr; + tree save_ccr = current_class_ref; + bool do_inject = (TREE_CODE (t) == METHOD_TYPE + && TREE_CODE (TREE_TYPE (t)) == DECLTYPE_TYPE); + if (do_inject) + { + /* DR 1207: 'this' is in scope in the trailing return type. */ + tree this_type = TREE_TYPE (TREE_VALUE (arg_types)); + inject_this_parameter (this_type, cp_type_quals (this_type)); + } + return_type = tsubst (TREE_TYPE (t), args, complain, in_decl); + + if (do_inject) + { + current_class_ptr = save_ccp; + current_class_ref = save_ccr; + } + if (return_type == error_mark_node) return error_mark_node; /* DR 486 clarifies that creation of a function type with an @@ -11344,12 +11368,6 @@ tsubst_function_type (tree t, if (abstract_virtuals_error_sfinae (ACU_RETURN, return_type, complain)) return error_mark_node; - /* Substitute the argument types. */ - arg_types = tsubst_arg_types (TYPE_ARG_TYPES (t), args, NULL_TREE, - complain, in_decl); - if (arg_types == error_mark_node) - return error_mark_node; - /* Construct a new type node and return it. */ if (TREE_CODE (t) == FUNCTION_TYPE) { Index: testsuite/g++.dg/cpp0x/decltype28.C =================================================================== --- testsuite/g++.dg/cpp0x/decltype28.C (revision 211024) +++ testsuite/g++.dg/cpp0x/decltype28.C (working copy) @@ -8,9 +8,9 @@ template void ft (F f, typename enable_if::type) {} template< class F, int N > -decltype(ft (F(), 0)) // { dg-error "depth" } +decltype(ft (F(), 0)) ft (F f, typename enable_if::type) {} int main() { - ft (0, 0); // { dg-message "from here" } + ft (0, 0); }