cp-tree.def (TYPEOF_TYPE): New code.
authorJason Merrill <jason@yorick.cygnus.com>
Mon, 26 Oct 1998 02:07:50 +0000 (02:07 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 26 Oct 1998 02:07:50 +0000 (21:07 -0500)
* 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

gcc/cp/ChangeLog
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/error.c
gcc/cp/parse.c
gcc/cp/parse.y
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/cp/tree.c

index 00e5f798d69f6966cc4342c6f66688f377d5bc2f..9bffbed91edae6137ad4f984466bdebef939ca5a 100644 (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.
index 2b249696dc16b68ad34b15f17c1d68f30e757228..3c50e8fe2994b9ccd0d0df31ea14be9cc123b56e 100644 (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:
index 025ae86d62855ee26e56de66f4b99b62a02c20dc..e9f7429cc76bea0a22c3c93794df7edff02b74b6 100644 (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));
index ba3517ef6f32121b8dc7735a95f394964200a17a..002473a781bfdb4c1febb871ac2e728ef4a1d155 100644 (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)]);
index e3861882f55806e39e94b02f4e973195d098c950..44e960049834f21191ec13347010974e9e55aec8 100644 (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:
index 4ce7d5b799a0adf7ad0334924cc3089769945358..e92cd7383eb296ba11849b3cc5c6438b2e8d0deb 100644 (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);
index ec1b5af46d60c362acdef045f9263ec80559b261..2f57bda4eea01ddcc7f03551ddfa1e4b702f33b5 100644 (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)]);
index aa7f2aa974223838b84b6bb4af39a92f432a352b..e2cf813f2210d765ddda4de194bf44ec5dd6d6fe 100644 (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);
+}
index db9f139b387b420f0c3c6bcf495e10294b9cab68..28e0d1c3e51f80d69fed664c2c3c4a320e602faf 100644 (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: