c-tree.h (build_arg_info): Declare.
authorNathan Froyd <froydnj@codesourcery.com>
Sun, 8 Aug 2010 17:44:53 +0000 (17:44 +0000)
committerNathan Froyd <froydnj@gcc.gnu.org>
Sun, 8 Aug 2010 17:44:53 +0000 (17:44 +0000)
* c-tree.h (build_arg_info): Declare.
* c-decl.c (build_arg_info): Define.
(get_parm_info): Call it.  Delete initialization code.
* c-parser.c (c_parser_parms_declarator): Likewise.
(c_parser_parms_list_declaractor): Likewise.

From-SVN: r163014

gcc/ChangeLog
gcc/c-decl.c
gcc/c-parser.c
gcc/c-tree.h

index b3bcc73e32bbae1a8719205527c762b14994c172..93cc8edbd74060ab33e82aff0ff45949c5608158 100644 (file)
@@ -1,3 +1,11 @@
+2010-08-08  Nathan Froyd  <froydnj@codesourcery.com>
+
+       * c-tree.h (build_arg_info): Declare.
+       * c-decl.c (build_arg_info): Define.
+       (get_parm_info): Call it.  Delete initialization code.
+       * c-parser.c (c_parser_parms_declarator): Likewise.
+       (c_parser_parms_list_declaractor): Likewise.
+
 2010-08-08  Nathan Froyd  <froydnj@codesourcery.com>
 
        * c-tree.h (c_arg_tag): Define.  Define a VEC containing it.
index e4e872d9b9d314016e52d895390128655f2c0c5b..ec6669219db77d8298197cc723498a7bb1021ab3 100644 (file)
@@ -6176,6 +6176,22 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag)
     }
 }
 
+/* Allocate and initialize a c_arg_info structure from the parser's
+   obstack.  */
+
+struct c_arg_info *
+build_arg_info (void)
+{
+  struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info);
+  ret->parms = NULL_TREE;
+  ret->tags = NULL;
+  ret->types = NULL_TREE;
+  ret->others = NULL_TREE;
+  ret->pending_sizes = NULL;
+  ret->had_vla_unspec = 0;
+  return ret;
+}
+
 /* Take apart the current scope and return a c_arg_info structure with
    info on a parameter list just parsed.
 
@@ -6188,8 +6204,8 @@ struct c_arg_info *
 get_parm_info (bool ellipsis)
 {
   struct c_binding *b = current_scope->bindings;
-  struct c_arg_info *arg_info = XOBNEW (&parser_obstack,
-                                       struct c_arg_info);
+  struct c_arg_info *arg_info = build_arg_info ();
+
   tree parms    = 0;
   VEC(c_arg_tag,gc) *tags = NULL;
   tree types    = 0;
@@ -6198,11 +6214,6 @@ get_parm_info (bool ellipsis)
   static bool explained_incomplete_types = false;
   bool gave_void_only_once_err = false;
 
-  arg_info->parms = 0;
-  arg_info->tags = 0;
-  arg_info->types = 0;
-  arg_info->others = 0;
-  arg_info->pending_sizes = 0;
   arg_info->had_vla_unspec = current_scope->had_vla_unspec;
 
   /* The bindings in this scope must not get put into a block.
index 306d46ba65f28491f6bc415cb3edcddc72101d3a..031c6887cad5ecacd375c9dea12345dc088a9d89 100644 (file)
@@ -194,7 +194,6 @@ typedef struct GTY(()) c_parser {
 
 static GTY (()) c_parser *the_parser;
 
-
 /* Read in and lex a single token, storing it in *TOKEN.  */
 
 static void
@@ -2672,13 +2671,8 @@ c_parser_parms_declarator (c_parser *parser, bool id_list_ok, tree attrs)
        }
       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
        {
-         struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info);
-         ret->parms = 0;
-         ret->tags = 0;
+         struct c_arg_info *ret = build_arg_info ();
          ret->types = list;
-         ret->others = 0;
-         ret->pending_sizes = 0;
-         ret->had_vla_unspec = 0;
          c_parser_consume_token (parser);
          pop_scope ();
          return ret;
@@ -2715,24 +2709,13 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs)
      declarations.  */
   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
     {
-      struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info);
-      ret->parms = 0;
-      ret->tags = 0;
-      ret->types = 0;
-      ret->others = 0;
-      ret->pending_sizes = 0;
-      ret->had_vla_unspec = 0;
+      struct c_arg_info *ret = build_arg_info ();
       c_parser_consume_token (parser);
       return ret;
     }
   if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
     {
-      struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info);
-      ret->parms = 0;
-      ret->tags = 0;
-      ret->others = 0;
-      ret->pending_sizes = 0;
-      ret->had_vla_unspec = 0;
+      struct c_arg_info *ret = build_arg_info ();
       /* Suppress -Wold-style-definition for this case.  */
       ret->types = error_mark_node;
       error_at (c_parser_peek_token (parser)->location,
index 745dd053a8c88332cde633a416a411f3f884c7dd..a04d45c8eb1fa78e8dc0047fc702f129eacce16b 100644 (file)
@@ -444,6 +444,7 @@ extern tree finish_enum (tree, tree, tree);
 extern void finish_function (void);
 extern tree finish_struct (location_t, tree, tree, tree,
                           struct c_struct_parse_info *);
+extern struct c_arg_info *build_arg_info (void);
 extern struct c_arg_info *get_parm_info (bool);
 extern tree grokfield (location_t, struct c_declarator *,
                       struct c_declspecs *, tree, tree *);