aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-04-16 11:13:40 -0400
committerJason Merrill <jason@redhat.com>2021-06-07 23:55:04 -0400
commitf07edb5d7f3e77218ec846a9382f7c1d23e67b71 (patch)
treeda1e0a78879e276c05375527a16e59507fa64c1f /gcc/cp
parent715614ec3ec5390293e508bb190335d28db1fa8b (diff)
downloadgcc-f07edb5d7f3e77218ec846a9382f7c1d23e67b71.zip
gcc-f07edb5d7f3e77218ec846a9382f7c1d23e67b71.tar.gz
gcc-f07edb5d7f3e77218ec846a9382f7c1d23e67b71.tar.bz2
c++: alias with same name as base fn [PR91706]
This is a bit complex. Looking up c<T> in the definition of D::c finds C::c, OK. Looking up c in the definition of E finds D::c, OK. Since the alias is not dependent, we strip it from the template argument, leaving using E = A<decltype(c<T>())>; where 'c' still refers to C::c. But instantiating E looks up 'c' again and finds D::c, which isn't a function, and sadness ensues. I think the bug here is looking up 'c' in D at instantiation time; the declaration we found before is not dependent. This seems to happen because baselink_for_fns gets BASELINK_BINFO wrong; it is supposed to be the base where lookup found the functions, C in this case. gcc/cp/ChangeLog: PR c++/91706 * semantics.c (baselink_for_fns): Fix BASELINK_BINFO. gcc/testsuite/ChangeLog: PR c++/91706 * g++.dg/template/lookup17.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/semantics.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d08c1dd..f506a23 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3663,8 +3663,10 @@ baselink_for_fns (tree fns)
cl = currently_open_derived_class (scope);
if (!cl)
cl = scope;
- cl = TYPE_BINFO (cl);
- return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE);
+ tree access_path = TYPE_BINFO (cl);
+ tree conv_path = (cl == scope ? access_path
+ : lookup_base (cl, scope, ba_any, NULL, tf_none));
+ return build_baselink (conv_path, access_path, fns, /*optype=*/NULL_TREE);
}
/* Returns true iff DECL is a variable from a function outside