This patch fixes pr 81899. It was an underlying bug exposed by my removal of LANG_TYPE_SPECIFIC from BOUND_TEMPLATE_TEMPLATE_PARM.

B_T_T_P happened to not set CLASSTYPE_USE_TEMPLATE, even though, by definition, they are template instantiations. However they also happened to not be DECL_HIDDEN, so we lucked out.

This patch adds an explicit check for not being a B_T_T_P before checking CLASSTYPE_USE_TEMPLATE.

applied to trunk.

nathan
--
Nathan Sidwell
2017-08-21  Nathan Sidwell  <nat...@acm.org>

	PR c++/81899
	* pt.c (instantiate_class_template_1):
	BOUND_TEMPLATE_TEMPLATE_PARM is never friend-injected.

	PR c++/81899
	* g++.dg/template/pr81899.C: New.

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 251221)
+++ cp/pt.c	(working copy)
@@ -10724,10 +10724,15 @@ instantiate_class_template_1 (tree type)
 		    adjust_processing_template_decl = true;
 		  --processing_template_decl;
 		}
-	      else if (!CLASSTYPE_USE_TEMPLATE (friend_type)
+	      else if (TREE_CODE (friend_type) != BOUND_TEMPLATE_TEMPLATE_PARM
+		       && !CLASSTYPE_USE_TEMPLATE (friend_type)
 		       && TYPE_HIDDEN_P (friend_type))
 		{
 		  /* friend class C;
Index: testsuite/g++.dg/template/pr81899.C
===================================================================
--- testsuite/g++.dg/template/pr81899.C	(revision 0)
+++ testsuite/g++.dg/template/pr81899.C	(working copy)
@@ -0,0 +1,11 @@
+// PR 81899 we tried to treat a bound-tpl-tpl-parm as-if a real record-type
+
+template <template <typename> class FunctorData>
+struct functor {
+  friend FunctorData<int>;
+  void foo();
+};
+
+template <typename> struct data;
+
+template<> void functor<data>::foo();

Reply via email to