Commit b2b7d40a by Jason Merrill Committed by Jason Merrill

cp-tree.h (TYPENAME_TYPE_FULLNAME): New macro.

	* cp-tree.h (TYPENAME_TYPE_FULLNAME): New macro.
	* parse.y (nested_name_specifier): Add 'template' case.
	(explicit_template_type): New rule.
	(typename_sub): Use it.
	* decl.c (make_typename_type): Handle getting a template-id for NAME.
	* pt.c (tsubst): Likewise.

From-SVN: r18296
parent 5feca984
Sat Feb 28 12:06:44 1998 Jason Merrill <jason@yorick.cygnus.com>
* cp-tree.h (TYPENAME_TYPE_FULLNAME): New macro.
* parse.y (nested_name_specifier): Add 'template' case.
(explicit_template_type): New rule.
(typename_sub): Use it.
* decl.c (make_typename_type): Handle getting a template-id for NAME.
* pt.c (tsubst): Likewise.
Fri Feb 27 11:17:50 1998 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (add_to_template_args): Fix thinko.
......
......@@ -4474,33 +4474,61 @@ make_typename_type (context, name)
tree context, name;
{
tree t, d;
tree fullname;
if (TREE_CODE_CLASS (TREE_CODE (name)) == 't')
name = TYPE_IDENTIFIER (name);
else if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
else if (TREE_CODE (name) != IDENTIFIER_NODE)
fullname = name;
if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
name = TREE_OPERAND (name, 0);
if (TREE_CODE (name) != IDENTIFIER_NODE)
my_friendly_abort (2000);
if (! uses_template_parms (context)
|| context == current_class_type)
{
if (IS_AGGR_TYPE (context))
t = lookup_field (context, name, 0, 1);
else
t = NULL_TREE;
if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR)
{
if (IS_AGGR_TYPE (context))
t = lookup_field (context, name, 0, 0);
else
t = NULL_TREE;
if (t == NULL_TREE || TREE_CODE (t) != TEMPLATE_DECL
|| TREE_CODE (DECL_RESULT (t)) != TYPE_DECL)
{
cp_error ("no class template named `%#T' in `%#T'",
name, context);
return error_mark_node;
}
if (t == NULL_TREE)
return lookup_template_class (t, TREE_OPERAND (fullname, 1),
NULL_TREE, context);
}
else
{
cp_error ("no type named `%#T' in `%#T'", name, context);
return error_mark_node;
if (IS_AGGR_TYPE (context))
t = lookup_field (context, name, 0, 1);
else
t = NULL_TREE;
if (t == NULL_TREE)
{
cp_error ("no type named `%#T' in `%#T'", name, context);
return error_mark_node;
}
return TREE_TYPE (t);
}
return TREE_TYPE (t);
}
if (processing_template_decl)
push_obstacks (&permanent_obstack, &permanent_obstack);
t = make_lang_type (TYPENAME_TYPE);
TYPENAME_TYPE_FULLNAME (t) = fullname;
d = build_decl (TYPE_DECL, name, t);
if (processing_template_decl)
pop_obstacks ();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -265,6 +265,7 @@ empty_parms ()
%type <ttype> new_initializer new_placement
%type <ttype> using_decl .poplevel
%type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
%type <ttype> explicit_template_type
/* in order to recognize aggr tags as defining and thus shadowing. */
%token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
%type <ttype> named_class_head_sans_basetype_defn
......@@ -3168,6 +3169,8 @@ nested_name_specifier:
nested_name_specifier_1
| nested_name_specifier nested_name_specifier_1
{ $$ = $2; }
| nested_name_specifier TEMPLATE template_type SCOPE
{ got_scope = $$ = complete_type (TREE_TYPE ($3)); }
;
/* Why the @#$%^& do type_name and notype_identifier need to be expanded
......@@ -3254,6 +3257,8 @@ typename_sub1:
$$ = TREE_TYPE ($$);
}
}
| typename_sub1 explicit_template_type SCOPE
{ got_scope = $$ = make_typename_type ($1, $2); }
;
typename_sub2:
......@@ -3285,6 +3290,11 @@ typename_sub2:
}
;
explicit_template_type:
TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
{ $$ = build_min_nt (TEMPLATE_ID_EXPR, $2, $4); }
;
complex_type_name:
global_scope type_name
{
......
......@@ -4288,7 +4288,8 @@ tsubst (t, args, in_decl)
case TYPENAME_TYPE:
{
tree ctx = tsubst (TYPE_CONTEXT (t), args, in_decl);
tree f = make_typename_type (ctx, TYPE_IDENTIFIER (t));
tree f = tsubst_copy (TYPENAME_TYPE_FULLNAME (t), args, in_decl);
f = make_typename_type (ctx, f);
return cp_build_type_variant
(f, TYPE_READONLY (f) || TYPE_READONLY (t),
TYPE_VOLATILE (f) || TYPE_VOLATILE (t));
......
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