From patchwork Wed May 28 20:00:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 353573 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 9E86014009F for ; Thu, 29 May 2014 06:03:32 +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=XIx759s/ZQqYoZxZ/ l8GGnK/kizENlVTk+bd8sIEMVIXLeGGs5uAX8P26BxZW5Z0fWWe0lanIAK3Avak6 H+Xk4cYrdF7WlRARuntOp7cVXVfOFp2zBaxCsUe4tklCzTo1mN6YBAMvg52+S6Ei jauHuQoq1qrQsaxZrTDLUi1fHM= 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=boY7wfklL/eibgWgFOIT7vj UsKM=; b=tepz36sY2Vod7kZ8CNv6Ksa7v6NpGb8ks5R21VUuV3dKPy+LuC9tkZk ibnRBzS21AvI0eU5mZwsBepXbRn3yYvZjjDXviuhaSZYHCIImdezIaqM3xlSDnz7 r0QfIlk2QEvCslOG0nsKsnvV+0HqNr1Nkljs4/orjwqOjnHWbr5M= Received: (qmail 24787 invoked by alias); 28 May 2014 20:03:26 -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 24777 invoked by uid 89); 28 May 2014 20:03:25 -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: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 28 May 2014 20:03:24 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4SK3LeN018513 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 May 2014 20:03:22 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4SK3L6B019128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 May 2014 20:03:21 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4SK3Lcw027952; Wed, 28 May 2014 20:03:21 GMT Received: from [192.168.1.4] (/79.33.215.223) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 May 2014 13:03:20 -0700 Message-ID: <5386406B.9050902@oracle.com> Date: Wed, 28 May 2014 22:00:43 +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> <53861796.7070309@oracle.com> In-Reply-To: <53861796.7070309@oracle.com> X-IsSubscribed: yes Hi again, On 05/28/2014 07:06 PM, Paolo Carlini wrote: > (In case I would have also to double check something weird I was > seeing if the injection happens for all method types...) In the meanwhile I investigated the reason of all those regressions I was seeing when injecting in all METHOD_TYPEs: while handling, eg, from cpp0x/access02.C: template struct foo_argument { template static Arg test(Ret (C::*)(Arg)); ... }; we may still have, *after* substituting the argument types, that the the TREE_TYPE of the 0-th argument is still dependent, eg, a TEMPLATE_TYPE_PARM. In such cases it seems to me clear that it doesn't make sense to inject it, we don't really know the type. Indeed, if we try, we ICE in type_of_this_parm. Thus the below, which passes testing. 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; + tree this_type = (TREE_CODE (t) == METHOD_TYPE + ? TREE_TYPE (TREE_VALUE (arg_types)) : NULL_TREE); + bool do_inject = this_type && !dependent_type_p (this_type); + if (do_inject) + { + /* DR 1207: 'this' is in scope in the trailing return type. */ + 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); } Index: testsuite/g++.dg/cpp0x/decltype59.C =================================================================== --- testsuite/g++.dg/cpp0x/decltype59.C (revision 0) +++ testsuite/g++.dg/cpp0x/decltype59.C (working copy) @@ -0,0 +1,41 @@ +// PR c++/57543 +// { dg-do compile { target c++11 } } + +template< typename > struct X +{ + void foo(); + auto bar() -> decltype( X::foo() ); +}; + +template< typename > struct Y +{ + void foo(); + template< typename > + auto bar() -> decltype( Y::foo() ); +}; + +template< typename > struct Z +{ + void foo(); + template< typename T > + auto bar() -> decltype( T::foo() ); +}; + +template< typename > struct K +{ + void foo(); + template< typename T > + auto bar() -> decltype( T::foo() ); +}; + +template<> +template<> +auto K::bar>() -> decltype( K::foo() ); + +int main() +{ + X().bar(); + Y().bar(); + Z().bar>(); + K().bar>(); +}