This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix 22147
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 18 Oct 2005 17:39:52 +0100
- Subject: [C++ PATCH] Fix 22147
I've installed this backport to fix 22147 on the 4.0 branch. One of my recent
patches caused a regression on that branch.
built & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2005-10-18 Nathan Sidwell <nathan@codesourcery.com>
PR c++/22147
Backport 2005-09-27 Mark Mitchell <mark@codesourcery.com>
* name-lookup.c (maybe_process_template_type_declaration): Don't
treat forward declarations of classes as templates just because
we're processing_template_decl.
* pt.c (tsubst_decl): Clear DECL_TEMPLATE_INFO for friend
functions.
PR c++/22147
Backport 2005-09-27 Mark Mitchell <mark@codesourcery.com>
* g++.dg/template/friend37.C: New test.
* g++.dg/parse/crash28.C: Adjust error markers.
Index: gcc/cp/name-lookup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/name-lookup.c,v
retrieving revision 1.109.4.11
diff -c -3 -p -r1.109.4.11 name-lookup.c
*** gcc/cp/name-lookup.c 18 Oct 2005 13:49:16 -0000 1.109.4.11
--- gcc/cp/name-lookup.c 18 Oct 2005 14:05:42 -0000
*************** maybe_process_template_type_declaration
*** 4521,4526 ****
--- 4521,4531 ----
is a forward-declaration of `A'. */
;
+ else if (b->kind == sk_namespace
+ && current_binding_level->kind != sk_namespace)
+ /* If this new type is being injected into a containing scope,
+ then it's not a template type. */
+ ;
else
{
gcc_assert (IS_AGGR_TYPE (type) || TREE_CODE (type) == ENUMERAL_TYPE);
Index: gcc/cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.978.2.34
diff -c -3 -p -r1.978.2.34 pt.c
*** gcc/cp/pt.c 17 Oct 2005 17:32:04 -0000 1.978.2.34
--- gcc/cp/pt.c 18 Oct 2005 14:05:49 -0000
*************** tsubst_decl (tree t, tree args, tsubst_f
*** 6453,6458 ****
--- 6453,6468 ----
&& !uses_template_parms (argvec))
tsubst_default_arguments (r);
}
+ else
+ DECL_TEMPLATE_INFO (r) = NULL_TREE;
/* Copy the list of befriending classes. */
for (friends = &DECL_BEFRIENDING_CLASSES (r);
Index: gcc/testsuite/g++.dg/parse/crash28.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/parse/crash28.C,v
retrieving revision 1.1.2.1
diff -c -3 -p -r1.1.2.1 crash28.C
*** gcc/testsuite/g++.dg/parse/crash28.C 11 Aug 2005 09:31:22 -0000 1.1.2.1
--- gcc/testsuite/g++.dg/parse/crash28.C 18 Oct 2005 14:06:17 -0000
***************
*** 6,14 ****
// Volker Reichelt <reichelt@gcc.gnu.org>
template <class _Tp> class insert_iterator<slist<_Tp> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
! template <class _Value> class insert_iterator<int > { // { dg-error "template parameters not used|_Value" }
hash_set<_Value>; // { dg-error "no type|expected" }
};
template<int> struct A<X<> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
! struct A {}; // { dg-error "template argument required" }
--- 6,14 ----
// Volker Reichelt <reichelt@gcc.gnu.org>
template <class _Tp> class insert_iterator<slist<_Tp> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
! template <class _Value> class insert_iterator<int > { // { dg-error "template" }
hash_set<_Value>; // { dg-error "no type|expected" }
};
template<int> struct A<X<> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
! struct A {};