This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix bug 372
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] Fix bug 372
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Fri, 01 Sep 2000 10:47:18 +0100
- Organization: Codesourcery LLC
Hi,
I've installed the attached patch and testcase which fixes bug
372 where we encounter a TYPENAME_TYPE in an out-of-class
definition of a nested class of a templated class. We already DTRT in
begin_class_definition (semantics.c), but this bit happens before that.
Also, the union tag error formatting was wrong.
built & tested on i686-pc-linux-gnu, approved by Mark.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-08-10 Nathan Sidwell <nathan@codesourcery.com>
* parse.y (named_class_head): Check for TYPENAME_TYPE. Simplify
union tag mismatch error reporting.
Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/parse.y,v
retrieving revision 1.188
diff -c -3 -p -r1.188 parse.y
*** parse.y 2000/08/04 00:02:19 1.188
--- parse.y 2000/08/10 09:32:26
*************** named_class_head:
*** 2384,2407 ****
{
if ($1.t != error_mark_node)
{
! $$.t = TREE_TYPE ($1.t);
$$.new_type_flag = $1.new_type_flag;
! if (current_aggr == union_type_node
! && TREE_CODE ($$.t) != UNION_TYPE)
! cp_pedwarn ("`union' tag used in declaring `%#T'",
! $$.t);
! else if (TREE_CODE ($$.t) == UNION_TYPE
! && current_aggr != union_type_node)
! cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
! else if (TREE_CODE ($$.t) == RECORD_TYPE)
/* We might be specializing a template with a different
class-key; deal. */
! CLASSTYPE_DECLARED_CLASS ($$.t)
= (current_aggr == class_type_node);
if ($2)
{
! maybe_process_partial_specialization ($$.t);
! xref_basetypes (current_aggr, $1.t, $$.t, $2);
}
}
}
--- 2384,2413 ----
{
if ($1.t != error_mark_node)
{
! tree type = TREE_TYPE ($1.t);
!
! $$.t = type;
$$.new_type_flag = $1.new_type_flag;
! if ((current_aggr == union_type_node)
! != (TREE_CODE (type) == UNION_TYPE))
! cp_pedwarn (current_aggr == union_type_node
! ? "`union' tag used in declaring `%#T'"
! : "non-`union' tag used in declaring `%#T'",
! type);
! else if (TREE_CODE (type) == RECORD_TYPE)
/* We might be specializing a template with a different
class-key; deal. */
! CLASSTYPE_DECLARED_CLASS (type)
= (current_aggr == class_type_node);
if ($2)
{
! if (TREE_CODE (type) == TYPENAME_TYPE)
! /* In a definition of a member class template, we
! will get here with an implicit typename, a
! TYPENAME_TYPE with a type. */
! type = TREE_TYPE (type);
! maybe_process_partial_specialization (type);
! xref_basetypes (current_aggr, $1.t, type, $2);
}
}
}
// Build don't link:
//
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 10 Aug 2000 <nathan@codesourcery.com>
// bug 372 We ICE'd on the out-of-class definition of a nested class of a
// class template.
struct Bar
{
};
template <class T>
struct Foo
{
struct Baz;
struct Biz;
struct Boz
: Bar
{
};
};
template <class T>
struct Foo<T>::Biz
{
};
template <class T>
struct Foo<T>::Baz
: Bar
{
};