From patchwork Tue May 27 13:30:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 352966 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 723AF140093 for ; Tue, 27 May 2014 23:32:53 +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:cc:subject:content-type; q=dns; s=default; b=Xo70icNAVfimrcD7dW1oxbWZ3W1EBjyvjWGsTgp/Q7b zDp5I7jZoGd2RBiacOG5eHIuQgs8/D1h+CjecCrp4OxTcQ06Hq2z3G5rzPKCR8Co MOzXeXTwCvIbhVDbzr4blhpEhROEko6f8T+MdjCxMkupnWkrRa0hb72AkRiBW1gI = 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:cc:subject:content-type; s=default; bh=hJ2CwCoRmHgJFCMPmAbLYz1AhM4=; b=SsL8GX58JeLNP6ULG LJuCtgfxm2EEpELBy7BFta9sfWcx0UG22q66+TlzcHdKqp2e6lkcxHdybDOdGBIu REjf7LDmoxrS2K5EdK/6rIIceY3od/8t9dfWnBdLU+sbWdcVhqpblBG7MLXqCEHz d0swPDvmNt2si8R6WU+ZX5Aa6U= Received: (qmail 9376 invoked by alias); 27 May 2014 13:32:47 -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 9365 invoked by uid 89); 27 May 2014 13:32:46 -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; Tue, 27 May 2014 13:32:43 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4RDWfuv020880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 May 2014 13:32:41 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4RDWeLb015799 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 May 2014 13:32:40 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4RDWdqx002059; Tue, 27 May 2014 13:32:39 GMT Received: from [192.168.1.4] (/79.37.220.139) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 27 May 2014 06:32:39 -0700 Message-ID: <5384935D.5020406@oracle.com> Date: Tue, 27 May 2014 15:30:05 +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: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 57543 X-IsSubscribed: yes Hi, here, in order to accept the code without an explicit this-> qualification, I propose to simply notice that instance == current_class_type. Tested x86_64-linux. Thanks! Paolo. //////////////////// /cp 2014-05-27 Paolo Carlini PR c++/57543 * call.c (build_new_method_call_1): In an unevaluated context allow calling a member function of the same class. /testsuite 2014-05-27 Paolo Carlini PR c++/57543 * g++.dg/cpp0x/decltype59.C: New. Index: cp/call.c =================================================================== --- cp/call.c (revision 210956) +++ cp/call.c (working copy) @@ -8000,6 +8000,20 @@ build_new_method_call_1 (tree instance, tree fns, we know we really need it. */ cand->first_arg = instance; } + else if (cp_unevaluated_operand != 0 + && current_class_type + && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (instance)), + current_class_type)) + { + /* For example (c++/57543): + + template< typename > struct X + { + void foo(); + auto bar() -> decltype( X::foo() ); + }; */ + gcc_assert (cand->first_arg == instance); + } else { if (complain & tf_error) 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,13 @@ +// PR c++/57543 +// { dg-do compile { target c++11 } } + +template< typename T> struct X +{ + void foo(); + auto bar() -> decltype( X::foo() ); +}; + +int main() +{ + X().bar(); +}