cp-tree.def (TYPEOF_TYPE): New code.

* cp-tree.def (TYPEOF_TYPE): New code.
	* error.c (dump_type_real): Handle it.
	* pt.c (tsubst): Likewise.
	* tree.c (search_tree): Likewise.
	* semantics.c (finish_typeof): New fn.
	* parse.y (typespec): Use it.
	* cp-tree.h: Declare it.

From-SVN: r23343
This commit is contained in:
Jason Merrill 1998-10-26 02:07:50 +00:00 committed by Jason Merrill
parent 86910c53b6
commit b894fc0596
9 changed files with 49 additions and 2 deletions

View File

@ -1,3 +1,13 @@
1998-10-26 Jason Merrill <jason@yorick.cygnus.com>
* cp-tree.def (TYPEOF_TYPE): New code.
* error.c (dump_type_real): Handle it.
* pt.c (tsubst): Likewise.
* tree.c (search_tree): Likewise.
* semantics.c (finish_typeof): New fn.
* parse.y (typespec): Use it.
* cp-tree.h: Declare it.
1998-10-26 Manfred Hollstein <manfred@s-direktnet.de>
* cp-tree.h (FORMAT_VBASE_NAME): Make definition unconditional.

View File

@ -149,6 +149,10 @@ DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", 't', 0)
TREE_TYPE is a _TYPE from a baseclass of `T'. */
DEFTREECODE (TYPENAME_TYPE, "typename_type", 't', 0)
/* A type designated by `__typeof (expr)'. TYPE_FIELDS is the
expression in question. */
DEFTREECODE (TYPEOF_TYPE, "typeof_type", 't', 0)
/* A thunk is a stub function.
Thunks are used to implement multiple inheritance:

View File

@ -3033,6 +3033,7 @@ extern void enter_scope_of PROTO((tree));
extern tree finish_base_specifier PROTO((tree, tree, int));
extern void finish_member_declaration PROTO((tree));
extern void check_multiple_declarators PROTO((void));
extern tree finish_typeof PROTO((tree));
/* in sig.c */
extern tree build_signature_pointer_type PROTO((tree));

View File

@ -328,6 +328,12 @@ dump_type_real (t, v, canonical_name)
OB_PUTID (TYPE_IDENTIFIER (t));
break;
case TYPEOF_TYPE:
OB_PUTS ("__typeof (");
dump_expr (TYPE_FIELDS (t), 1);
OB_PUTC (')');
break;
default:
sorry ("`%s' not supported by dump_type",
tree_code_name[(int) TREE_CODE (t)]);

View File

@ -5760,7 +5760,7 @@ case 399:
break;}
case 400:
#line 1792 "parse.y"
{ yyval.ftype.t = TREE_TYPE (yyvsp[-1].ttype);
{ yyval.ftype.t = finish_typeof (yyvsp[-1].ttype);
yyval.ftype.new_type_flag = 0; ;
break;}
case 401:

View File

@ -1789,7 +1789,7 @@ typespec:
| complete_type_name
{ $$.t = $1; $$.new_type_flag = 0; }
| TYPEOF '(' expr ')'
{ $$.t = TREE_TYPE ($3);
{ $$.t = finish_typeof ($3);
$$.new_type_flag = 0; }
| TYPEOF '(' type_id ')'
{ $$.t = groktypename ($3.t);

View File

@ -5841,6 +5841,9 @@ tsubst (t, args, in_decl)
(TREE_CODE (t), tsubst (TREE_OPERAND (t, 0), args, in_decl),
tsubst (TREE_OPERAND (t, 1), args, in_decl));
case TYPEOF_TYPE:
return TREE_TYPE (tsubst_expr (TYPE_FIELDS (t), args, in_decl));
default:
sorry ("use of `%s' in template",
tree_code_name [(int) TREE_CODE (t)]);

View File

@ -1604,3 +1604,25 @@ check_multiple_declarators ()
cp_error ("multiple declarators in template declaration");
}
tree
finish_typeof (expr)
tree expr;
{
if (processing_template_decl)
{
tree t;
push_obstacks_nochange ();
end_temporary_allocation ();
t = make_lang_type (TYPEOF_TYPE);
CLASSTYPE_GOT_SEMICOLON (t) = 1;
TYPE_FIELDS (t) = expr;
pop_obstacks ();
return t;
}
return TREE_TYPE (expr);
}

View File

@ -1686,6 +1686,7 @@ search_tree (t, func)
case TYPENAME_TYPE:
case UNION_TYPE:
case ENUMERAL_TYPE:
case TYPEOF_TYPE:
break;
case POINTER_TYPE: