re PR c++/22147 (ICE in get_bindings)

PR c++/22147
	* 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
	* g++.dg/template/friend37.C: New test.
	* g++.dg/parse/crash28.C: Adjust error markers.

From-SVN: r104713
This commit is contained in:
Mark Mitchell 2005-09-27 23:31:57 +00:00 committed by Mark Mitchell
parent 57f0d086d5
commit c43e95f8f5
6 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,12 @@
2005-09-27 Mark Mitchell <mark@codesourcery.com>
PR c++/22147
* 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.
2005-09-26 Jason Merrill <jason@redhat.com>
PR c++/13764

View File

@ -4689,6 +4689,11 @@ maybe_process_template_type_declaration (tree type, int is_friend,
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);

View File

@ -6510,6 +6510,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
&& !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);

View File

@ -1,3 +1,9 @@
2005-09-27 Mark Mitchell <mark@codesourcery.com>
PR c++/22147
* g++.dg/template/friend37.C: New test.
* g++.dg/parse/crash28.C: Adjust error markers.
2005-09-27 Jakub Jelinek <jakub@redhat.com>
PR fortran/18518

View File

@ -6,9 +6,9 @@
// 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" }
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 {}; // { dg-error "template argument required" }
struct A {};

View File

@ -0,0 +1,15 @@
// PR c++/22147
template<typename> struct A;
template<typename T> void foo(A<T>* p) { *p; }
template<typename> struct A
{
friend void foo<class X>(A<X>*);
};
void bar()
{
foo<int>(0);
}