Skip to content
Snippets Groups Projects
  • Nathaniel Shead's avatar
    79209273
    c++/modules: Handle instantiating already tsubsted template friend classes [PR115801] · 79209273
    Nathaniel Shead authored
    
    With modules it may be the case that a template friend class provided
    with a qualified name is not found by name lookup at instantiation time,
    due to the class not being exported from its module.  This causes issues
    in tsubst_friend_class which did not handle this case.
    
    This is caused by the named friend class not actually requiring
    tsubsting.  This was already worked around for the "found by name
    lookup" case (g++.dg/template/friend5.C), but it looks like there's no
    need to do name lookup at all for this particular case to work.
    
    We do need to be careful to continue to do name lookup to handle
    templates from an outer current instantiation though; this patch adds a
    new testcase for this as well.  This should not impact modules (because
    exportingness will only affect namespace lookup).
    
    	PR c++/115801
    
    gcc/cp/ChangeLog:
    
    	* pt.cc (tsubst_friend_class): Return the type immediately when
    	no tsubsting or name lookup is required.
    
    gcc/testsuite/ChangeLog:
    
    	* g++.dg/modules/tpl-friend-16_a.C: New test.
    	* g++.dg/modules/tpl-friend-16_b.C: New test.
    	* g++.dg/template/friend82.C: New test.
    
    Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
    Reviewed-by: default avatarPatrick Palka <ppalka@redhat.com>
    Reviewed-by: default avatarJason Merrill <jason@redhat.com>
    79209273
    History
    c++/modules: Handle instantiating already tsubsted template friend classes [PR115801]
    Nathaniel Shead authored
    
    With modules it may be the case that a template friend class provided
    with a qualified name is not found by name lookup at instantiation time,
    due to the class not being exported from its module.  This causes issues
    in tsubst_friend_class which did not handle this case.
    
    This is caused by the named friend class not actually requiring
    tsubsting.  This was already worked around for the "found by name
    lookup" case (g++.dg/template/friend5.C), but it looks like there's no
    need to do name lookup at all for this particular case to work.
    
    We do need to be careful to continue to do name lookup to handle
    templates from an outer current instantiation though; this patch adds a
    new testcase for this as well.  This should not impact modules (because
    exportingness will only affect namespace lookup).
    
    	PR c++/115801
    
    gcc/cp/ChangeLog:
    
    	* pt.cc (tsubst_friend_class): Return the type immediately when
    	no tsubsting or name lookup is required.
    
    gcc/testsuite/ChangeLog:
    
    	* g++.dg/modules/tpl-friend-16_a.C: New test.
    	* g++.dg/modules/tpl-friend-16_b.C: New test.
    	* g++.dg/template/friend82.C: New test.
    
    Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
    Reviewed-by: default avatarPatrick Palka <ppalka@redhat.com>
    Reviewed-by: default avatarJason Merrill <jason@redhat.com>