diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-04-10 22:49:11 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-04-10 22:49:11 +0200 |
commit | b447b28c5e434eb949e30985a7c2d49f6aa592fe (patch) | |
tree | 942477203dd8b4098eb50cb3c29b741ccb1724c1 /gcc/cp | |
parent | 3bbd6768bd4f185afd48319b0ce0c0875d62bc6a (diff) | |
download | gcc-b447b28c5e434eb949e30985a7c2d49f6aa592fe.zip gcc-b447b28c5e434eb949e30985a7c2d49f6aa592fe.tar.gz gcc-b447b28c5e434eb949e30985a7c2d49f6aa592fe.tar.bz2 |
re PR c++/80176 (cannot bind reference to static member function using object access expression)
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.
From-SVN: r246825
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/tree.c | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0a19eaa..b7cbca5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-04-10 Jakub Jelinek <jakub@redhat.com> + + 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. + 2017-04-10 Marek Polacek <polacek@redhat.com> PR sanitizer/80348 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9939135..acb9b8e 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -105,6 +105,17 @@ 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, we can get + here e.g. from reference_binding. If BASELINK_FUNCTIONS is + OVERLOAD, the overload is resolved first if possible through + resolve_address_of_overloaded_function. */ + 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) |