From: Kriang Lerdsuwanakij Date: Tue, 24 Aug 2004 14:13:50 +0000 (+0000) Subject: re PR c++/16706 (ICE in finish_member_declaration, at cp/semantics.c:2126) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e59f7322effb7542b4311ec731ce45565ef600f6;p=gcc.git re PR c++/16706 (ICE in finish_member_declaration, at cp/semantics.c:2126) 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ddeb19ed164..9ac0c74dfc4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-08-24 Kriang Lerdsuwanakij + + PR c++/16706 + * search.c (friend_accessible_p): Increment processing_template_decl + when deal with TEMPLATE_DECL of SCOPE. + 2004-08-24 Nathan Sidwell PR c++/17149 diff --git a/gcc/cp/search.c b/gcc/cp/search.c index df5804b29ef..81226d13d33 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 59138e2cd2a..7264db71fe6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2004-08-24 Kriang Lerdsuwanakij + + PR c++/16706 + * g++.dg/template/crash21.C: New test. + * g++.dg/template/crash22.C: Likewise. + 2004-08-24 Nathan Sidwell 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 index 00000000000..8b674910e52 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash21.C @@ -0,0 +1,40 @@ +// { dg-do compile } + +// Origin: Debian GCC maintainers +// Wolfgang Bangerth + +// PR c++/16706: Dependent type calculation during access checking + +template struct B { + B() throw() {} + struct S { }; + static int i; + typedef unsigned short int dummy; +}; + +template +struct allocator: B<_Tp> { + template struct rebind + { typedef allocator<_Tp1> other; }; +}; + +template +struct X { + typename allocator::template rebind::other i; + typedef int* dummy; +}; + +template class A { + typedef typename X >::dummy dummy; + template class XWrapper; +}; + + +template +template struct A::XWrapper +{ + XWrapper() {} + X > x; +}; + +template class A::XWrapper; diff --git a/gcc/testsuite/g++.dg/template/crash22.C b/gcc/testsuite/g++.dg/template/crash22.C new file mode 100644 index 00000000000..4d0cfaa999e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash22.C @@ -0,0 +1,26 @@ +// { dg-do compile } + +// Origin: Debian GCC maintainers +// Volker Reichelt + +// PR c++/16706: Dependent type calculation during access checking + +template struct A +{ + A(); + template struct X {}; +}; + +template struct B +{ + typename A::template X x; + template struct C; +}; + +template template struct B::C +{ + C() {} + A a; +}; + +template struct B::C;