aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-10-26 02:07:50 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-10-25 21:07:50 -0500
commitb894fc059610e2054fe98329ee1e00a249116a89 (patch)
treed4dc0a4806de0efac7979dd8cc215ec76794f37e
parent86910c53b6301f301d093a8de8e8794e90c5ee00 (diff)
downloadgcc-b894fc059610e2054fe98329ee1e00a249116a89.zip
gcc-b894fc059610e2054fe98329ee1e00a249116a89.tar.gz
gcc-b894fc059610e2054fe98329ee1e00a249116a89.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/cp-tree.def4
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/error.c6
-rw-r--r--gcc/cp/parse.c2
-rw-r--r--gcc/cp/parse.y2
-rw-r--r--gcc/cp/pt.c3
-rw-r--r--gcc/cp/semantics.c22
-rw-r--r--gcc/cp/tree.c1
9 files changed, 49 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 00e5f79..9bffbed 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 2b24969..3c50e8f 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -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:
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 025ae86..e9f7429 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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));
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index ba3517e..002473a 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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)]);
diff --git a/gcc/cp/parse.c b/gcc/cp/parse.c
index e386188..44e9600 100644
--- a/gcc/cp/parse.c
+++ b/gcc/cp/parse.c
@@ -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:
diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y
index 4ce7d5b..e92cd73 100644
--- a/gcc/cp/parse.y
+++ b/gcc/cp/parse.y
@@ -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);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ec1b5af..2f57bda 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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)]);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index aa7f2aa..e2cf813 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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);
+}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index db9f139..28e0d1c 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1686,6 +1686,7 @@ search_tree (t, func)
case TYPENAME_TYPE:
case UNION_TYPE:
case ENUMERAL_TYPE:
+ case TYPEOF_TYPE:
break;
case POINTER_TYPE: