re PR c++/15701 (ICE with friends and template template parameter)
authorMark Mitchell <mark@codesourcery.com>
Mon, 31 May 2004 22:48:30 +0000 (22:48 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 31 May 2004 22:48:30 +0000 (22:48 +0000)
PR c++/15701
* friend.c (add_friend): Do not try to perform access checks for
functions from dependent classes.

PR c++/15701
* g++.dg/template/friend29.C: New test.

From-SVN: r82516

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

index 4ead672ef934c97237bff78a0961f3c155febf67..4549203275b081c2e8def2cfd7eda4480e092459 100644 (file)
@@ -1,3 +1,9 @@
+2004-05-31  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15701
+       * friend.c (add_friend): Do not try to perform access checks for
+       functions from dependent classes.
+
 2004-05-31  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * cxx-pretty-print.c (pp_cxx_colon_colon): Expor.
index e55adaa8bc0cfb7704e789599b60084bf68fe7f3..f815b99f0b92b89f17d38dd73a4c5e72c080aee8 100644 (file)
@@ -164,7 +164,11 @@ add_friend (tree type, tree decl, bool complain)
     }
 
   if (DECL_CLASS_SCOPE_P (decl))
-    perform_or_defer_access_check (TYPE_BINFO (DECL_CONTEXT (decl)), decl);
+    {
+      tree class_binfo = TYPE_BINFO (DECL_CONTEXT (decl));
+      if (!uses_template_parms (BINFO_TYPE (class_binfo)))
+       perform_or_defer_access_check (class_binfo, decl);
+    }
 
   maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1);
 
index a337797b1c8be2fc988aa8f4767f4b91efb3e814..67b637b3ac1063db23b537f00398eed2b605b9cc 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-31  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15701
+       * g++.dg/template/friend29.C: New test.
+
 2004-05-31  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        PR c/15749
diff --git a/gcc/testsuite/g++.dg/template/friend29.C b/gcc/testsuite/g++.dg/template/friend29.C
new file mode 100644 (file)
index 0000000..1c0c6f0
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/15701
+
+template<template<int> class T> struct A : T<0>
+{
+    void foo();
+    template<template<int> class U> friend void A<U>::foo();
+};
+
+template<int> struct B {};
+
+A<B> a;