Commit b894fc05 by Jason Merrill Committed by Jason Merrill

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
parent 86910c53
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> 1998-10-26 Manfred Hollstein <manfred@s-direktnet.de>
* cp-tree.h (FORMAT_VBASE_NAME): Make definition unconditional. * cp-tree.h (FORMAT_VBASE_NAME): Make definition unconditional.
......
...@@ -149,6 +149,10 @@ DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", 't', 0) ...@@ -149,6 +149,10 @@ DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", 't', 0)
TREE_TYPE is a _TYPE from a baseclass of `T'. */ TREE_TYPE is a _TYPE from a baseclass of `T'. */
DEFTREECODE (TYPENAME_TYPE, "typename_type", 't', 0) 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. /* A thunk is a stub function.
Thunks are used to implement multiple inheritance: Thunks are used to implement multiple inheritance:
......
...@@ -3033,6 +3033,7 @@ extern void enter_scope_of PROTO((tree)); ...@@ -3033,6 +3033,7 @@ extern void enter_scope_of PROTO((tree));
extern tree finish_base_specifier PROTO((tree, tree, int)); extern tree finish_base_specifier PROTO((tree, tree, int));
extern void finish_member_declaration PROTO((tree)); extern void finish_member_declaration PROTO((tree));
extern void check_multiple_declarators PROTO((void)); extern void check_multiple_declarators PROTO((void));
extern tree finish_typeof PROTO((tree));
/* in sig.c */ /* in sig.c */
extern tree build_signature_pointer_type PROTO((tree)); extern tree build_signature_pointer_type PROTO((tree));
......
...@@ -328,6 +328,12 @@ dump_type_real (t, v, canonical_name) ...@@ -328,6 +328,12 @@ dump_type_real (t, v, canonical_name)
OB_PUTID (TYPE_IDENTIFIER (t)); OB_PUTID (TYPE_IDENTIFIER (t));
break; break;
case TYPEOF_TYPE:
OB_PUTS ("__typeof (");
dump_expr (TYPE_FIELDS (t), 1);
OB_PUTC (')');
break;
default: default:
sorry ("`%s' not supported by dump_type", sorry ("`%s' not supported by dump_type",
tree_code_name[(int) TREE_CODE (t)]); tree_code_name[(int) TREE_CODE (t)]);
......
...@@ -5760,7 +5760,7 @@ case 399: ...@@ -5760,7 +5760,7 @@ case 399:
break;} break;}
case 400: case 400:
#line 1792 "parse.y" #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; ; yyval.ftype.new_type_flag = 0; ;
break;} break;}
case 401: case 401:
......
...@@ -1789,7 +1789,7 @@ typespec: ...@@ -1789,7 +1789,7 @@ typespec:
| complete_type_name | complete_type_name
{ $$.t = $1; $$.new_type_flag = 0; } { $$.t = $1; $$.new_type_flag = 0; }
| TYPEOF '(' expr ')' | TYPEOF '(' expr ')'
{ $$.t = TREE_TYPE ($3); { $$.t = finish_typeof ($3);
$$.new_type_flag = 0; } $$.new_type_flag = 0; }
| TYPEOF '(' type_id ')' | TYPEOF '(' type_id ')'
{ $$.t = groktypename ($3.t); { $$.t = groktypename ($3.t);
......
...@@ -5841,6 +5841,9 @@ tsubst (t, args, in_decl) ...@@ -5841,6 +5841,9 @@ tsubst (t, args, in_decl)
(TREE_CODE (t), tsubst (TREE_OPERAND (t, 0), args, in_decl), (TREE_CODE (t), tsubst (TREE_OPERAND (t, 0), args, in_decl),
tsubst (TREE_OPERAND (t, 1), 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: default:
sorry ("use of `%s' in template", sorry ("use of `%s' in template",
tree_code_name [(int) TREE_CODE (t)]); tree_code_name [(int) TREE_CODE (t)]);
......
...@@ -1604,3 +1604,25 @@ check_multiple_declarators () ...@@ -1604,3 +1604,25 @@ check_multiple_declarators ()
cp_error ("multiple declarators in template declaration"); 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);
}
...@@ -1686,6 +1686,7 @@ search_tree (t, func) ...@@ -1686,6 +1686,7 @@ search_tree (t, func)
case TYPENAME_TYPE: case TYPENAME_TYPE:
case UNION_TYPE: case UNION_TYPE:
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
case TYPEOF_TYPE:
break; break;
case POINTER_TYPE: case POINTER_TYPE:
......
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