re PR c++/81899 (ICE: Segmentation fault)
authorNathan Sidwell <nathan@acm.org>
Mon, 21 Aug 2017 13:29:20 +0000 (13:29 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 21 Aug 2017 13:29:20 +0000 (13:29 +0000)
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.

From-SVN: r251227

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/pr81899.C [new file with mode: 0644]

index 72a0554..ba9583a 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-21  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/81899
+       * pt.c (instantiate_class_template_1):
+       BOUND_TEMPLATE_TEMPLATE_PARM is never friend-injected.
+
 2017-08-18  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/81514
index bf1f75d..8d816c7 100644 (file)
@@ -10724,7 +10724,8 @@ 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 53505ef..f35db2b 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-21  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/81899
+       * g++.dg/template/pr81899.C: New.
+
 2017-08-21  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/81900
diff --git a/gcc/testsuite/g++.dg/template/pr81899.C b/gcc/testsuite/g++.dg/template/pr81899.C
new file mode 100644 (file)
index 0000000..2db57cf
--- /dev/null
@@ -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();