https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86747

--- Comment #6 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Author: aoliva
Date: Thu Dec  6 23:18:40 2018
New Revision: 266875

URL: https://gcc.gnu.org/viewcvs?rev=266875&root=gcc&view=rev
Log:
[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.

Added:
    trunk/gcc/testsuite/g++.dg/pr86747.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Reply via email to