Commit b3399d18 by Nathan Froyd Committed by Nathan Froyd

c-tree.h (build_arg_info): Declare.

	* 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
parent e60bf9d4
2010-08-08 Nathan Froyd <froydnj@codesourcery.com> 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. * c-tree.h (c_arg_tag): Define. Define a VEC containing it.
(struct c_arg_info): Change type of tags field. (struct c_arg_info): Change type of tags field.
* c-decl.c (grokdeclarator): Update for changed type of tags field. * c-decl.c (grokdeclarator): Update for changed type of tags field.
......
...@@ -6176,6 +6176,22 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) ...@@ -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 /* Take apart the current scope and return a c_arg_info structure with
info on a parameter list just parsed. info on a parameter list just parsed.
...@@ -6188,8 +6204,8 @@ struct c_arg_info * ...@@ -6188,8 +6204,8 @@ struct c_arg_info *
get_parm_info (bool ellipsis) get_parm_info (bool ellipsis)
{ {
struct c_binding *b = current_scope->bindings; struct c_binding *b = current_scope->bindings;
struct c_arg_info *arg_info = XOBNEW (&parser_obstack, struct c_arg_info *arg_info = build_arg_info ();
struct c_arg_info);
tree parms = 0; tree parms = 0;
VEC(c_arg_tag,gc) *tags = NULL; VEC(c_arg_tag,gc) *tags = NULL;
tree types = 0; tree types = 0;
...@@ -6198,11 +6214,6 @@ get_parm_info (bool ellipsis) ...@@ -6198,11 +6214,6 @@ get_parm_info (bool ellipsis)
static bool explained_incomplete_types = false; static bool explained_incomplete_types = false;
bool gave_void_only_once_err = 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; arg_info->had_vla_unspec = current_scope->had_vla_unspec;
/* The bindings in this scope must not get put into a block. /* The bindings in this scope must not get put into a block.
......
...@@ -194,7 +194,6 @@ typedef struct GTY(()) c_parser { ...@@ -194,7 +194,6 @@ typedef struct GTY(()) c_parser {
static GTY (()) c_parser *the_parser; static GTY (()) c_parser *the_parser;
/* Read in and lex a single token, storing it in *TOKEN. */ /* Read in and lex a single token, storing it in *TOKEN. */
static void static void
...@@ -2672,13 +2671,8 @@ c_parser_parms_declarator (c_parser *parser, bool id_list_ok, tree attrs) ...@@ -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)) if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
{ {
struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info); struct c_arg_info *ret = build_arg_info ();
ret->parms = 0;
ret->tags = 0;
ret->types = list; ret->types = list;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
c_parser_consume_token (parser); c_parser_consume_token (parser);
pop_scope (); pop_scope ();
return ret; return ret;
...@@ -2715,24 +2709,13 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs) ...@@ -2715,24 +2709,13 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs)
declarations. */ declarations. */
if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
{ {
struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info); struct c_arg_info *ret = build_arg_info ();
ret->parms = 0;
ret->tags = 0;
ret->types = 0;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
c_parser_consume_token (parser); c_parser_consume_token (parser);
return ret; return ret;
} }
if (c_parser_next_token_is (parser, CPP_ELLIPSIS)) if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
{ {
struct c_arg_info *ret = XOBNEW (&parser_obstack, struct c_arg_info); struct c_arg_info *ret = build_arg_info ();
ret->parms = 0;
ret->tags = 0;
ret->others = 0;
ret->pending_sizes = 0;
ret->had_vla_unspec = 0;
/* Suppress -Wold-style-definition for this case. */ /* Suppress -Wold-style-definition for this case. */
ret->types = error_mark_node; ret->types = error_mark_node;
error_at (c_parser_peek_token (parser)->location, error_at (c_parser_peek_token (parser)->location,
......
...@@ -444,6 +444,7 @@ extern tree finish_enum (tree, tree, tree); ...@@ -444,6 +444,7 @@ extern tree finish_enum (tree, tree, tree);
extern void finish_function (void); extern void finish_function (void);
extern tree finish_struct (location_t, tree, tree, tree, extern tree finish_struct (location_t, tree, tree, tree,
struct c_struct_parse_info *); struct c_struct_parse_info *);
extern struct c_arg_info *build_arg_info (void);
extern struct c_arg_info *get_parm_info (bool); extern struct c_arg_info *get_parm_info (bool);
extern tree grokfield (location_t, struct c_declarator *, extern tree grokfield (location_t, struct c_declarator *,
struct c_declspecs *, tree, tree *); struct c_declspecs *, tree, tree *);
......
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