Message ID | 20170410132234.GE1809@tucnak |
---|---|
State | New |
Headers | show |
On 04/10/2017 09:22 AM, Jakub Jelinek wrote: > 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; Ok, that makes sense. This patch is ok, with ... > + /* For static member function recurse on the BASELINK. */ Mention that overloads of more than one function go via a different path. nathan
--- 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;