* pt.c (tsubst_friend_class): Check for NULL.
authorMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 28 Apr 1999 13:14:20 +0000 (13:14 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 28 Apr 1999 13:14:20 +0000 (13:14 +0000)
From-SVN: r26688

gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.pt/friend42.C [new file with mode: 0644]

index 12c8a95..a56523b 100644 (file)
@@ -4641,7 +4641,7 @@ tsubst_friend_class (friend_tmpl, args)
 
      Here, in the scope of (say) S<int>, `S' is bound to a TYPE_DECL
      for `S<int>', not the TEMPLATE_DECL.  */
-  if (!DECL_CLASS_TEMPLATE_P (tmpl))
+  if (!tmpl || !DECL_CLASS_TEMPLATE_P (tmpl))
     {
       tmpl = lookup_name (DECL_NAME (friend_tmpl), /*prefer_type=*/1);
       tmpl = maybe_get_template_decl_from_type_decl (tmpl);
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend42.C b/gcc/testsuite/g++.old-deja/g++.pt/friend42.C
new file mode 100644 (file)
index 0000000..dcbfd46
--- /dev/null
@@ -0,0 +1,10 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <class T>
+struct S {
+  template <class U>
+  friend struct S2;
+};
+
+template struct S<int>;