Commit 2604412d by Jason Merrill Committed by Jason Merrill

parse.y (explicit_template_type): Remove TEMPLATE keyword.

	* parse.y (explicit_template_type): Remove TEMPLATE keyword.
	(nested_name_specifier): And add it before this use.
	(typename_sub0): And this use.  Also add use without the keyword.
	(typename_sub1): Likewise.
	* pt.c (instantiate_class_template): Don't actually instantiate
	anything if our type uses template parms.

From-SVN: r18358
parent fc470718
Mon Mar 2 12:11:06 1998 Jason Merrill <jason@yorick.cygnus.com>
* parse.y (explicit_template_type): Remove TEMPLATE keyword.
(nested_name_specifier): And add it before this use.
(typename_sub0): And this use. Also add use without the keyword.
(typename_sub1): Likewise.
* pt.c (instantiate_class_template): Don't actually instantiate
anything if our type uses template parms.
Mon Mar 2 11:04:59 1998 Jim Wilson <wilson@cygnus.com> Mon Mar 2 11:04:59 1998 Jim Wilson <wilson@cygnus.com>
* decl.c (start_function): Don't call temporary_allocation for a * decl.c (start_function): Don't call temporary_allocation for a
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3169,8 +3169,8 @@ nested_name_specifier: ...@@ -3169,8 +3169,8 @@ nested_name_specifier:
nested_name_specifier_1 nested_name_specifier_1
| nested_name_specifier nested_name_specifier_1 | nested_name_specifier nested_name_specifier_1
{ $$ = $2; } { $$ = $2; }
| nested_name_specifier explicit_template_type SCOPE | nested_name_specifier TEMPLATE explicit_template_type SCOPE
{ got_scope = $$ = make_typename_type ($1, $2); } { got_scope = $$ = make_typename_type ($1, $3); }
; ;
/* Why the @#$%^& do type_name and notype_identifier need to be expanded /* Why the @#$%^& do type_name and notype_identifier need to be expanded
...@@ -3238,14 +3238,10 @@ typename_sub0: ...@@ -3238,14 +3238,10 @@ typename_sub0:
} }
| typename_sub1 template_type %prec EMPTY | typename_sub1 template_type %prec EMPTY
{ $$ = TREE_TYPE ($2); } { $$ = TREE_TYPE ($2); }
| typename_sub1 identifier '<' template_arg_list_opt
template_close_bracket
{
$$ = build_min_nt (TEMPLATE_ID_EXPR, $2, $4);
$$ = make_typename_type ($1, $$);
}
| typename_sub1 explicit_template_type %prec EMPTY | typename_sub1 explicit_template_type %prec EMPTY
{ $$ = make_typename_type ($1, $2); } { $$ = make_typename_type ($1, $2); }
| typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
{ $$ = make_typename_type ($1, $3); }
; ;
typename_sub1: typename_sub1:
...@@ -3269,6 +3265,8 @@ typename_sub1: ...@@ -3269,6 +3265,8 @@ typename_sub1:
} }
| typename_sub1 explicit_template_type SCOPE | typename_sub1 explicit_template_type SCOPE
{ got_scope = $$ = make_typename_type ($1, $2); } { got_scope = $$ = make_typename_type ($1, $2); }
| typename_sub1 TEMPLATE explicit_template_type SCOPE
{ got_scope = $$ = make_typename_type ($1, $3); }
; ;
typename_sub2: typename_sub2:
...@@ -3301,8 +3299,8 @@ typename_sub2: ...@@ -3301,8 +3299,8 @@ typename_sub2:
; ;
explicit_template_type: explicit_template_type:
TEMPLATE identifier '<' template_arg_list_opt template_close_bracket identifier '<' template_arg_list_opt template_close_bracket
{ $$ = build_min_nt (TEMPLATE_ID_EXPR, $2, $4); } { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
; ;
complex_type_name: complex_type_name:
......
...@@ -3022,8 +3022,8 @@ instantiate_class_template (type) ...@@ -3022,8 +3022,8 @@ instantiate_class_template (type)
CLASSTYPE_INTERFACE_ONLY (type) = interface_only; CLASSTYPE_INTERFACE_ONLY (type) = interface_only;
SET_CLASSTYPE_INTERFACE_UNKNOWN_X (type, interface_unknown); SET_CLASSTYPE_INTERFACE_UNKNOWN_X (type, interface_unknown);
CLASSTYPE_VTABLE_NEEDS_WRITING (type) CLASSTYPE_VTABLE_NEEDS_WRITING (type)
= ! CLASSTYPE_INTERFACE_ONLY (type) = (! CLASSTYPE_INTERFACE_ONLY (type)
&& CLASSTYPE_INTERFACE_KNOWN (type); && CLASSTYPE_INTERFACE_KNOWN (type));
} }
else else
{ {
...@@ -3031,8 +3031,8 @@ instantiate_class_template (type) ...@@ -3031,8 +3031,8 @@ instantiate_class_template (type)
SET_CLASSTYPE_INTERFACE_UNKNOWN_X SET_CLASSTYPE_INTERFACE_UNKNOWN_X
(type, CLASSTYPE_INTERFACE_UNKNOWN (pattern)); (type, CLASSTYPE_INTERFACE_UNKNOWN (pattern));
CLASSTYPE_VTABLE_NEEDS_WRITING (type) CLASSTYPE_VTABLE_NEEDS_WRITING (type)
= ! CLASSTYPE_INTERFACE_ONLY (type) = (! CLASSTYPE_INTERFACE_ONLY (type)
&& CLASSTYPE_INTERFACE_KNOWN (type); && CLASSTYPE_INTERFACE_KNOWN (type));
} }
} }
else else
...@@ -3067,6 +3067,21 @@ instantiate_class_template (type) ...@@ -3067,6 +3067,21 @@ instantiate_class_template (type)
TYPE_PACKED (type) = TYPE_PACKED (pattern); TYPE_PACKED (type) = TYPE_PACKED (pattern);
TYPE_ALIGN (type) = TYPE_ALIGN (pattern); TYPE_ALIGN (type) = TYPE_ALIGN (pattern);
CLASSTYPE_LOCAL_TYPEDECLS (type) = CLASSTYPE_LOCAL_TYPEDECLS (pattern);
/* If this is a partial instantiation, don't tsubst anything. We will
only use this type for implicit typename, so the actual contents don't
matter. All that matters is whether a particular name is a type. */
if (uses_template_parms (type))
{
TYPE_BINFO_BASETYPES (type) = TYPE_BINFO_BASETYPES (pattern);
TYPE_FIELDS (type) = TYPE_FIELDS (pattern);
TYPE_METHODS (type) = TYPE_METHODS (pattern);
CLASSTYPE_TAGS (type) = CLASSTYPE_TAGS (pattern);
TYPE_SIZE (type) = integer_zero_node;
goto end;
}
{ {
tree binfo = TYPE_BINFO (type); tree binfo = TYPE_BINFO (type);
tree pbases = TYPE_BINFO_BASETYPES (pattern); tree pbases = TYPE_BINFO_BASETYPES (pattern);
...@@ -3089,9 +3104,7 @@ instantiate_class_template (type) ...@@ -3089,9 +3104,7 @@ instantiate_class_template (type)
cp_error cp_error
("base type `%T' of `%T' fails to be a struct or class type", ("base type `%T' of `%T' fails to be a struct or class type",
TREE_TYPE (elt), type); TREE_TYPE (elt), type);
else if (! uses_template_parms (type) else if (TYPE_SIZE (complete_type (TREE_TYPE (elt))) == NULL_TREE)
&& (TYPE_SIZE (complete_type (TREE_TYPE (elt)))
== NULL_TREE))
cp_error ("base class `%T' of `%T' has incomplete type", cp_error ("base class `%T' of `%T' has incomplete type",
TREE_TYPE (elt), type); TREE_TYPE (elt), type);
} }
...@@ -3101,8 +3114,6 @@ instantiate_class_template (type) ...@@ -3101,8 +3114,6 @@ instantiate_class_template (type)
} }
} }
CLASSTYPE_LOCAL_TYPEDECLS (type) = CLASSTYPE_LOCAL_TYPEDECLS (pattern);
field_chain = &TYPE_FIELDS (type); field_chain = &TYPE_FIELDS (type);
for (t = CLASSTYPE_TAGS (pattern); t; t = TREE_CHAIN (t)) for (t = CLASSTYPE_TAGS (pattern); t; t = TREE_CHAIN (t))
...@@ -3131,9 +3142,8 @@ instantiate_class_template (type) ...@@ -3131,9 +3142,8 @@ instantiate_class_template (type)
tree r = tsubst (t, args, NULL_TREE); tree r = tsubst (t, args, NULL_TREE);
if (TREE_CODE (r) == VAR_DECL) if (TREE_CODE (r) == VAR_DECL)
{ {
if (! uses_template_parms (r)) pending_statics = perm_tree_cons (NULL_TREE, r, pending_statics);
pending_statics = perm_tree_cons (NULL_TREE, r, pending_statics); /* Perhaps we should do more of grokfield here. */
/* Perhaps I should do more of grokfield here. */
start_decl_1 (r); start_decl_1 (r);
DECL_IN_AGGR_P (r) = 1; DECL_IN_AGGR_P (r) = 1;
DECL_EXTERNAL (r) = 1; DECL_EXTERNAL (r) = 1;
...@@ -3153,87 +3163,79 @@ instantiate_class_template (type) ...@@ -3153,87 +3163,79 @@ instantiate_class_template (type)
grok_op_properties (t, DECL_VIRTUAL_P (t), 0); grok_op_properties (t, DECL_VIRTUAL_P (t), 0);
} }
if (! uses_template_parms (type)) /* Construct the DECL_FRIENDLIST for the new class type. */
typedecl = TYPE_MAIN_DECL (type);
for (t = DECL_FRIENDLIST (TYPE_MAIN_DECL (pattern));
t != NULL_TREE;
t = TREE_CHAIN (t))
{ {
/* Construct the DECL_FRIENDLIST for the new class type. */ tree friends;
typedecl = TYPE_MAIN_DECL (type);
for (t = DECL_FRIENDLIST (TYPE_MAIN_DECL (pattern));
t != NULL_TREE;
t = TREE_CHAIN (t))
{
tree friends;
DECL_FRIENDLIST (typedecl) DECL_FRIENDLIST (typedecl)
= tree_cons (TREE_PURPOSE (t), NULL_TREE, = tree_cons (TREE_PURPOSE (t), NULL_TREE,
DECL_FRIENDLIST (typedecl)); DECL_FRIENDLIST (typedecl));
for (friends = TREE_VALUE (t); for (friends = TREE_VALUE (t);
friends != NULL_TREE; friends != NULL_TREE;
friends = TREE_CHAIN (friends)) friends = TREE_CHAIN (friends))
{
if (TREE_PURPOSE (friends) == error_mark_node)
{ {
if (TREE_PURPOSE (friends) == error_mark_node) TREE_VALUE (DECL_FRIENDLIST (typedecl))
{ = tree_cons (error_mark_node,
TREE_VALUE (DECL_FRIENDLIST (typedecl)) tsubst_friend_function (TREE_VALUE (friends),
= tree_cons (error_mark_node, args),
tsubst_friend_function (TREE_VALUE (friends), TREE_VALUE (DECL_FRIENDLIST (typedecl)));
args), }
TREE_VALUE (DECL_FRIENDLIST (typedecl))); else
} {
else TREE_VALUE (DECL_FRIENDLIST (typedecl))
{ = tree_cons (tsubst (TREE_PURPOSE (friends), args, NULL_TREE),
TREE_VALUE (DECL_FRIENDLIST (typedecl)) NULL_TREE,
= tree_cons (tsubst (TREE_PURPOSE (friends), args, NULL_TREE), TREE_VALUE (DECL_FRIENDLIST (typedecl)));
NULL_TREE,
TREE_VALUE (DECL_FRIENDLIST (typedecl)));
}
} }
} }
}
t = CLASSTYPE_FRIEND_CLASSES (type) t = CLASSTYPE_FRIEND_CLASSES (type)
= tsubst (CLASSTYPE_FRIEND_CLASSES (pattern), args, NULL_TREE); = tsubst (CLASSTYPE_FRIEND_CLASSES (pattern), args, NULL_TREE);
/* This does injection for friend classes. */ /* This does injection for friend classes. */
for (; t; t = TREE_CHAIN (t)) for (; t; t = TREE_CHAIN (t))
TREE_VALUE (t) = xref_tag_from_type (TREE_VALUE (t), NULL_TREE, 1); TREE_VALUE (t) = xref_tag_from_type (TREE_VALUE (t), NULL_TREE, 1);
/* This does injection for friend functions. */ /* This does injection for friend functions. */
if (!processing_template_decl) if (!processing_template_decl)
{ {
t = tsubst (DECL_TEMPLATE_INJECT (template), args, NULL_TREE); t = tsubst (DECL_TEMPLATE_INJECT (template), args, NULL_TREE);
for (; t; t = TREE_CHAIN (t)) for (; t; t = TREE_CHAIN (t))
{ {
tree d = TREE_VALUE (t); tree d = TREE_VALUE (t);
if (TREE_CODE (d) == TYPE_DECL) if (TREE_CODE (d) == TYPE_DECL)
/* Already injected. */; /* Already injected. */;
else else
pushdecl (d); pushdecl (d);
} }
} }
for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t)) for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t))
if (TREE_CODE (t) == FIELD_DECL) if (TREE_CODE (t) == FIELD_DECL)
{ {
TREE_TYPE (t) = complete_type (TREE_TYPE (t)); TREE_TYPE (t) = complete_type (TREE_TYPE (t));
require_complete_type (t); require_complete_type (t);
} }
type = finish_struct_1 (type, 0); type = finish_struct_1 (type, 0);
CLASSTYPE_GOT_SEMICOLON (type) = 1; CLASSTYPE_GOT_SEMICOLON (type) = 1;
repo_template_used (type); repo_template_used (type);
if (at_eof && TYPE_BINFO_VTABLE (type) != NULL_TREE) if (at_eof && TYPE_BINFO_VTABLE (type) != NULL_TREE)
finish_prevtable_vardecl (NULL, TYPE_BINFO_VTABLE (type)); finish_prevtable_vardecl (NULL, TYPE_BINFO_VTABLE (type));
}
else
{
TYPE_SIZE (type) = integer_zero_node;
CLASSTYPE_METHOD_VEC (type)
= finish_struct_methods (type, TYPE_METHODS (type), 1);
}
end:
TYPE_BEING_DEFINED (type) = 0; TYPE_BEING_DEFINED (type) = 0;
popclass (0); popclass (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