re PR c++/16706 (ICE in finish_member_declaration, at cp/semantics.c:2126)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Tue, 24 Aug 2004 14:13:50 +0000 (14:13 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Tue, 24 Aug 2004 14:13:50 +0000 (14:13 +0000)
PR c++/16706
* search.c (friend_accessible_p): Increment processing_template_decl
when deal with TEMPLATE_DECL of SCOPE.

* g++.dg/template/crash21.C: New test.
* g++.dg/template/crash22.C: Likewise.

From-SVN: r86482

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

index ddeb19ed1643f1d216ed9c1d344fc3fc9a9ff371..9ac0c74dfc4f9649d72648aab01416b9ec080bc4 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-24  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/16706
+       * search.c (friend_accessible_p): Increment processing_template_decl
+       when deal with TEMPLATE_DECL of SCOPE.
+
 2004-08-24  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/17149
index df5804b29ef3aa96e5faf126f7c3388020f336e1..81226d13d33ae34b37fc7393f139d14966433c3a 100644 (file)
@@ -835,10 +835,26 @@ friend_accessible_p (tree scope, tree decl, tree binfo)
 
       /* Or an instantiation of something which is a friend.  */
       if (DECL_TEMPLATE_INFO (scope))
-       return friend_accessible_p (DECL_TI_TEMPLATE (scope), decl, binfo);
+       {
+         int ret;
+         /* Increment processing_template_decl to make sure that
+            dependent_type_p works correctly.  */
+         ++processing_template_decl;
+         ret = friend_accessible_p (DECL_TI_TEMPLATE (scope), decl, binfo);
+         --processing_template_decl;
+         return ret;
+       }
     }
   else if (CLASSTYPE_TEMPLATE_INFO (scope))
-    return friend_accessible_p (CLASSTYPE_TI_TEMPLATE (scope), decl, binfo);
+    {
+      int ret;
+      /* Increment processing_template_decl to make sure that
+        dependent_type_p works correctly.  */
+      ++processing_template_decl;
+      ret = friend_accessible_p (CLASSTYPE_TI_TEMPLATE (scope), decl, binfo);
+      --processing_template_decl;
+      return ret;
+    }
 
   return 0;
 }
index 59138e2cd2a9aa4657e5aa2fa245f86976573e34..7264db71fe6bfe0412e8fdb5bfaf1ca004828cd7 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-24  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/16706
+       * g++.dg/template/crash21.C: New test.
+       * g++.dg/template/crash22.C: Likewise.
+
 2004-08-24  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/17149
diff --git a/gcc/testsuite/g++.dg/template/crash21.C b/gcc/testsuite/g++.dg/template/crash21.C
new file mode 100644 (file)
index 0000000..8b67491
--- /dev/null
@@ -0,0 +1,40 @@
+// { dg-do compile }
+
+// Origin: Debian GCC maintainers <debian-gcc@lists.debian.org>
+//        Wolfgang Bangerth <bangerth@dealii.org>
+
+// PR c++/16706: Dependent type calculation during access checking
+
+template <typename> struct B { 
+    B() throw() {} 
+    struct S { }; 
+    static int i; 
+    typedef unsigned short int dummy; 
+}; 
+template <typename _Tp> 
+struct allocator: B<_Tp> { 
+    template<typename _Tp1> struct rebind 
+    { typedef allocator<_Tp1> other; }; 
+}; 
+template<typename T, typename> 
+struct X { 
+    typename allocator<T>::template rebind<int>::other i; 
+    typedef int* dummy; 
+}; 
+template <class T> class A { 
+    typedef typename X<T,allocator<T> >::dummy dummy; 
+    template <class TP> class XWrapper; 
+}; 
+template <class T> 
+template <class TP> struct A<T>::XWrapper<TP *> 
+{ 
+    XWrapper() {} 
+    X<int,allocator<int> > x; 
+}; 
+template class A<int>::XWrapper<int *>;
diff --git a/gcc/testsuite/g++.dg/template/crash22.C b/gcc/testsuite/g++.dg/template/crash22.C
new file mode 100644 (file)
index 0000000..4d0cfaa
--- /dev/null
@@ -0,0 +1,26 @@
+// { dg-do compile }
+
+// Origin: Debian GCC maintainers <debian-gcc@lists.debian.org>
+//        Volker Reichelt <reichelt@gcc.gnu.org>
+
+// PR c++/16706: Dependent type calculation during access checking
+
+template<typename> struct A 
+{
+    A();
+    template<typename> struct X {};
+};
+
+template<typename T> struct B
+{
+    typename A<T>::template X<int> x;
+    template<typename> struct C;
+};
+
+template<typename T> template<typename U> struct B<T>::C<U*>
+{
+    C() {}
+    A<int> a;
+};
+
+template struct B<int>::C<int*>;