aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>1999-04-28 13:14:20 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-04-28 13:14:20 +0000
commitbc639f90588947747ddf9ef1f5d11fe3c811e3fd (patch)
tree0d7ab89f02b457d13a0b18f717b9a8273f7d65f7
parent94ff101fbd669d656b0120207cc2bf3ca311ece1 (diff)
downloadgcc-bc639f90588947747ddf9ef1f5d11fe3c811e3fd.zip
gcc-bc639f90588947747ddf9ef1f5d11fe3c811e3fd.tar.gz
gcc-bc639f90588947747ddf9ef1f5d11fe3c811e3fd.tar.bz2
* pt.c (tsubst_friend_class): Check for NULL.
From-SVN: r26688
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/friend42.C10
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 12c8a95..a56523b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..dcbfd46
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/friend42.C
@@ -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>;