From ac90ae18fb641f365ce349efbbaf8b88a4f96b8e Mon Sep 17 00:00:00 2001 From: Douglas Gregor <doug.gregor@gmail.com> Date: Tue, 15 Jan 2008 20:56:55 +0000 Subject: [PATCH] re PR c++/34399 (ICE on invalid friend declaration of variadic template) 2008-01-15 Douglas Gregor <doug.gregor@gmail.com> PR c++/34399 * friend.c (do_friend): Don't query TYPE_BEING_DEFINED unless we know we have a class type. 2008-01-15 Douglas Gregor <doug.gregor@gmail.com> PR c++/34399 * g++.dg/cpp0x/vt-34399.C: New. * g++.dg/template/friend50.C: New. From-SVN: r131552 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/friend.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/cpp0x/vt-34399.C | 10 ++++++++++ gcc/testsuite/g++.dg/template/friend50.C | 9 +++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/vt-34399.C create mode 100644 gcc/testsuite/g++.dg/template/friend50.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6fec22f833de..cb78daa5d553 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-01-15 Douglas Gregor <doug.gregor@gmail.com> + + PR c++/34399 + * friend.c (do_friend): Don't query TYPE_BEING_DEFINED unless we + know we have a class type. + 2008-01-15 Douglas Gregor <doug.gregor@gmail.com> PR c++/34751 diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 95f98c453973..094501b109a3 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -468,7 +468,7 @@ do_friend (tree ctype, tree declarator, tree decl, the process of being defined. */ if (class_template_depth || COMPLETE_TYPE_P (ctype) - || TYPE_BEING_DEFINED (ctype)) + || (CLASS_TYPE_P (ctype) && TYPE_BEING_DEFINED (ctype))) { if (DECL_TEMPLATE_INFO (decl)) /* DECL is a template specialization. No need to diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c6184f91da7e..c9d0e6a6923d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-01-15 Douglas Gregor <doug.gregor@gmail.com> + + PR c++/34399 + * g++.dg/cpp0x/vt-34399.C: New. + * g++.dg/template/friend50.C: New. + 2008-01-15 Douglas Gregor <doug.gregor@gmail.com> PR c++/34751 diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34399.C b/gcc/testsuite/g++.dg/cpp0x/vt-34399.C new file mode 100644 index 000000000000..542fae586ca8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34399.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++0x" } +template<int...> struct A +{ + void foo(); +}; + +struct B +{ + template<int N> friend void A<N>::A::foo(); // { dg-error "declared as friend" } +}; diff --git a/gcc/testsuite/g++.dg/template/friend50.C b/gcc/testsuite/g++.dg/template/friend50.C new file mode 100644 index 000000000000..93c429ab161c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend50.C @@ -0,0 +1,9 @@ +// PR c++/34399 +template<int> struct X +{ + void foo(); +}; + +struct Y { + template<long N> friend void X<N>::X::foo(); // { dg-error "declared as friend" } +}; -- GitLab