aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2018-12-06 23:18:40 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2018-12-06 23:18:40 +0000
commitd7711adcd5226995063342631e1ce5c2ff055981 (patch)
treed18e6d7e133cf87e121f40a607230f110db42421 /gcc
parent0d699def39bb937e3fddbd8149892594447b7f0d (diff)
downloadgcc-d7711adcd5226995063342631e1ce5c2ff055981.zip
gcc-d7711adcd5226995063342631e1ce5c2ff055981.tar.gz
gcc-d7711adcd5226995063342631e1ce5c2ff055981.tar.bz2
[PR86747] tsubst friend tpl ctxt before looking it up for dupes
When a member template is redeclared as a friend, we enter the context of the member before looking it up, and then we check that the decls are compatible. However, when the member template references template types of the enclosing context, say an enclosing template class, the compare fails because the friend decl is already tsubsted, whereas the looked up name isn't. The problem is that the enclosing context is taken from the friend declaration before tsubsting it, so we look up in the context of the generic template instead of that of the tsubsted one we're specializing. The solution is to tsubst the enclosing context when it's a non-namespace scope. for gcc/cp/ChangeLog PR c++/86747 * pt.c (tsubst_friend_class): Enter tsubsted class context. for gcc/testsuite/ChangeLog PR c++/86747 * g++.dg/pr86747.C: New. From-SVN: r266875
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c5
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/pr86747.C8
4 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 727f2d4..e092c44 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2018-12-06 Alexandre Oliva <aoliva@redhat.com>
+ PR c++/86747
+ * pt.c (tsubst_friend_class): Enter tsubsted class context.
+
PR c++/86397
* except.c (build_noexcept_spec): Resolve nondependent
expressions.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 90fb3ae..8560e58 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10558,7 +10558,10 @@ tsubst_friend_class (tree friend_tmpl, tree args)
if (TREE_CODE (context) == NAMESPACE_DECL)
push_nested_namespace (context);
else
- push_nested_class (context);
+ {
+ context = tsubst (context, args, tf_error, NULL_TREE);
+ push_nested_class (context);
+ }
tmpl = lookup_name_real (DECL_NAME (friend_tmpl), /*prefer_type=*/false,
/*non_class=*/false, /*block_p=*/false,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index eddb457..1871663 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2018-12-06 Alexandre Oliva <aoliva@redhat.com>
+ PR c++/86747
+ * g++.dg/pr86747.C: New.
+
PR c++/86397
* g++.dg/cpp0x/pr86397-1.C: New.
* g++.dg/cpp0x/pr86397-2.C: New.
diff --git a/gcc/testsuite/g++.dg/pr86747.C b/gcc/testsuite/g++.dg/pr86747.C
new file mode 100644
index 0000000..5b0a0bb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr86747.C
@@ -0,0 +1,8 @@
+// { dg-do compile }
+
+template <typename T> class A {
+ template <void (A::*p)()> class C; // #1
+ template <void (A::*q)()> friend class C; // #2
+};
+
+A<double> a;