From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4275 invoked by alias); 10 Apr 2017 13:22:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4250 invoked by uid 89); 10 Apr 2017 13:22:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=yo, xm, xn, xo X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Apr 2017 13:22:38 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8E9EC054C29; Mon, 10 Apr 2017 13:22:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E8E9EC054C29 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E8E9EC054C29 Received: from tucnak.zalov.cz (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AD935C899; Mon, 10 Apr 2017 13:22:38 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v3ADMZPZ025478; Mon, 10 Apr 2017 15:22:36 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v3ADMY7G025477; Mon, 10 Apr 2017 15:22:34 +0200 Date: Mon, 10 Apr 2017 13:22:00 -0000 From: Jakub Jelinek To: Nathan Sidwell Cc: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: Patch ping Message-ID: <20170410132234.GE1809@tucnak> Reply-To: Jakub Jelinek References: <20170410121835.GD1809@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00448.txt.bz2 On Mon, Apr 10, 2017 at 08:41:28AM -0400, Nathan Sidwell wrote: > On 04/10/2017 08:18 AM, Jakub Jelinek wrote: > > Hi! > > > > I'd like to ping 2 patches: > > > > P2 PR c++/80176 > > http://gcc.gnu.org/ml/gcc-patches/2017-04/msg00027.html > > reference binding to static member function > > This smells fishy. There's no reason one cannot have an overload set > containing both static and non-static functions, in any order. So it'll be > 'random' as to which member of the set OVL_CURRENT looks at. I actually don't know if I need the OVL_CURRENT thing, maybe not. On the testcase there is an overloaded static member function and I don't get an error on that, just on the non-overloaded one. I've tried: struct X { static void foo(); static void baz(int); static int baz(double); void m(int); void n(int); int n(float); } x; void X::foo() {} static void bar() {} void (&r1)() = x.foo; void (&r2)() = X::foo; void (&r3)() = bar; void (&r4)(int) = x.baz; int (&r5)(double) = x.baz; void (&r6)(int) = X::baz; int (&r7)(double) = X::baz; void (&r8)(int) = x.m; void (&r9)(int) = x.n; int (&r10)(float) = x.n; and there I see COMPONENT_REF with BASELINK second operand with BASELINK_FUNCTIONS being an overload only for the methods. And even if I try overload with mixed methods and static member functions, lvalue_kind with that is only called when seeing the invalid binding to method: struct X { void o(unsigned char); static void o(int); void o(double); } x; void (&r12)(int) = x.o; void (&r13)(double) = x.o; Thus, would it be acceptable to omit the OVL_CURRENT as in (tested so far just on the updated ref23.C with additional test from the above r12 snippet, of course would perform full bootstrap/regtest with that)? 2017-04-08 Jakub Jelinek PR c++/80176 * tree.c (lvalue_kind): For COMPONENT_REF with BASELINK second operand, if it is a static member function, recurse on the BASELINK. * g++.dg/init/ref23.C: New test. --- gcc/cp/tree.c.jj 2017-04-07 21:17:57.078208891 +0200 +++ gcc/cp/tree.c 2017-04-10 15:18:57.941508441 +0200 @@ -105,6 +105,14 @@ lvalue_kind (const_tree ref) return op1_lvalue_kind; case COMPONENT_REF: + if (BASELINK_P (TREE_OPERAND (ref, 1))) + { + tree fn = BASELINK_FUNCTIONS (TREE_OPERAND (ref, 1)); + + /* For static member function recurse on the BASELINK. */ + if (TREE_CODE (fn) == FUNCTION_DECL && DECL_STATIC_FUNCTION_P (fn)) + return lvalue_kind (TREE_OPERAND (ref, 1)); + } op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0)); /* Look at the member designator. */ if (!op1_lvalue_kind) --- gcc/testsuite/g++.dg/init/ref23.C.jj 2017-04-10 15:17:04.823911276 +0200 +++ gcc/testsuite/g++.dg/init/ref23.C 2017-04-10 15:18:07.504133944 +0200 @@ -0,0 +1,15 @@ +// PR c++/80176 +// { dg-do compile } + +struct X { static void foo(); static void baz(int); static int baz(double); } x; +struct Y { void o(unsigned char); static void o(int); void o(double); } y; +void X::foo() {} +static void bar() {} +void (&r1)() = x.foo; +void (&r2)() = X::foo; +void (&r3)() = bar; +void (&r4)(int) = x.baz; +int (&r5)(double) = x.baz; +void (&r6)(int) = X::baz; +int (&r7)(double) = X::baz; +void (&r8)(int) = y.o; Jakub