Commit ca099ac8 by Mark Mitchell Committed by Mark Mitchell

re PR c++/5333 (ICE on nested template classes using other nested template classes)

	PR c++/5333
	* cp-tree.h (CLASSTYPE_PRIMARY_TEMPLATE): New macro.
	* parser.c (cp_parser_diagnose_invalid_type_name): Use it.
	* pt.c (instantiate_class_template): Don't try to instantiate
	dependent types.
	(resolve_typename_type): Use CLASSTYPE_PRIMARY_TEMPLATE.

	PR c++/5333
	* g++.dg/parse/fused-params1.C: Adjust error messages.
	* g++.dg/template/nested3.C: New test.

From-SVN: r63354
parent 463f02cd
2003-02-23 Mark Mitchell <mark@codesourcery.com>
PR c++/5333
* cp-tree.h (CLASSTYPE_PRIMARY_TEMPLATE): New macro.
* parser.c (cp_parser_diagnose_invalid_type_name): Use it.
* pt.c (instantiate_class_template): Don't try to instantiate
dependent types.
(resolve_typename_type): Use CLASSTYPE_PRIMARY_TEMPLATE.
2003-02-21 Mark Mitchell <mark@codesourcery.com>
PR c++/9749
......
......@@ -2316,6 +2316,12 @@ struct lang_decl GTY(())
#define ENUM_TI_ARGS(NODE) \
TI_ARGS (ENUM_TEMPLATE_INFO (NODE))
/* For a template instantiation TYPE, returns the TYPE corresponding
to the primary template. */
#define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE) \
TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE \
(CLASSTYPE_TI_TEMPLATE ((TYPE)))))
/* Like DECL_TI_TEMPLATE, but for an ENUMERAL_, RECORD_, or UNION_TYPE. */
#define TYPE_TI_TEMPLATE(NODE) \
(TI_TEMPLATE (TYPE_TEMPLATE_INFO (NODE)))
......
......@@ -1954,10 +1954,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser)
template (which will have an empty TYPE_FIELDs),
to the main version. */
if (CLASSTYPE_USE_TEMPLATE (base_type))
base_type = (TREE_TYPE
(DECL_TEMPLATE_RESULT
(DECL_PRIMARY_TEMPLATE
(CLASSTYPE_TI_TEMPLATE (base_type)))));
base_type = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (base_type);
for (field = TYPE_FIELDS (base_type);
field;
field = TREE_CHAIN (field))
......@@ -4526,6 +4523,7 @@ cp_parser_unary_operator (cp_token* token)
/* Parse a new-expression.
new-expression:
:: [opt] new new-placement [opt] new-type-id new-initializer [opt]
:: [opt] new new-placement [opt] ( type-id ) new-initializer [opt]
......
......@@ -5151,7 +5151,9 @@ instantiate_class_template (type)
if (type == error_mark_node)
return error_mark_node;
if (TYPE_BEING_DEFINED (type) || COMPLETE_TYPE_P (type))
if (TYPE_BEING_DEFINED (type)
|| COMPLETE_TYPE_P (type)
|| dependent_type_p (type))
return type;
/* Figure out which template is being instantiated. */
......@@ -11526,6 +11528,10 @@ resolve_typename_type (tree type, bool only_current_p)
to look inside it. */
if (only_current_p && !currently_open_class (scope))
return error_mark_node;
/* If SCOPE is a partial instantiation, it will not have a valid
TYPE_FIELDS list, so use the original template. */
if (CLASSTYPE_USE_TEMPLATE (scope))
scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope);
/* Enter the SCOPE so that name lookup will be resolved as if we
were in the class definition. In particular, SCOPE will no
longer be considered a dependent type. */
......
2003-02-23 Mark Mitchell <mark@codesourcery.com>
PR c++/5333
* g++.dg/parse/fused-params1.C: Adjust error messages.
* g++.dg/template/nested3.C: New test.
2003-02-24 Alan Modra <amodra@bigpond.net.au>
* g++.dg/abi/param1.C: New test.
......
......@@ -3,9 +3,9 @@
// { dg-do compile }
template <int N,typename T> struct A
{
{ // { dg-error "" }
typedef T X;
template <int M> void foo (const A<M,X>&); // { dg-error "candidate" }
template <int M> void foo (const A<M,X>&);
};
template <int N,int M,typename T>
......
template <class T1, class T2>
class A {
template <class S>
class SubA {
int _k;
};
T1 _t1;
T2 _t2;
};
template <class U>
class B {
class SubB1 {
B _i;
};
class SubB2 {
int _j;
};
A<U,SubB1>::SubA<SubB2> _a; // { dg-error "" }
};
int main() {
B<char> objB;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment