c-decl.c (set_array_declarator_type): Rename to set_array_declarator_inner.

* c-decl.c (set_array_declarator_type): Rename to
	set_array_declarator_inner.
	(build_c_parm, build_attrs_declarator, build_function_declarator):
	New functions.
	(make_pointer_declarator): Call build_attrs_declarator.
	* c-tree.h (set_array_declarator_type): Rename to
	set_array_declarator_inner.
	(build_c_parm, build_attrs_declarator, build_function_declarator):
	New prototypes.
	* c-parse.in (after_type_declarator,
	parm_declarator_starttypename, parm_declarator_nostarttypename,
	notype_declarator, absdcl_maybe_attribute, direct_absdcl1, parm,
	firstparm): Use these functions

From-SVN: r86367
This commit is contained in:
Joseph Myers 2004-08-21 23:49:46 +01:00 committed by Joseph Myers
parent 60919bce32
commit 00325bce05
4 changed files with 86 additions and 47 deletions

View File

@ -1,3 +1,19 @@
2004-08-21 Joseph S. Myers <jsm@polyomino.org.uk>
* c-decl.c (set_array_declarator_type): Rename to
set_array_declarator_inner.
(build_c_parm, build_attrs_declarator, build_function_declarator):
New functions.
(make_pointer_declarator): Call build_attrs_declarator.
* c-tree.h (set_array_declarator_type): Rename to
set_array_declarator_inner.
(build_c_parm, build_attrs_declarator, build_function_declarator):
New prototypes.
* c-parse.in (after_type_declarator,
parm_declarator_starttypename, parm_declarator_nostarttypename,
notype_declarator, absdcl_maybe_attribute, direct_absdcl1, parm,
firstparm): Use these functions
2004-08-21 Joseph S. Myers <jsm@polyomino.org.uk>
* c-decl.c (build_array_declarator, set_array_declarator_type,

View File

@ -2629,7 +2629,7 @@ shadow_tag_warned (tree declspecs, int warned)
nevertheless a complete type (not currently implemented by GCC),
false otherwise. The declarator is constructed as an ARRAY_REF
(to be decoded by grokdeclarator), whose operand 0 is what's on the
left of the [] (filled by in set_array_declarator_type) and operand 1
left of the [] (filled by in set_array_declarator_inner) and operand 1
is the expression inside; whose TREE_TYPE is the type qualifiers and
which has TREE_STATIC set if "static" is used. */
@ -2661,7 +2661,7 @@ build_array_declarator (tree expr, tree quals, bool static_p,
C99 grammar. */
tree
set_array_declarator_type (tree decl, tree type, bool abstract_p)
set_array_declarator_inner (tree decl, tree type, bool abstract_p)
{
TREE_OPERAND (decl, 0) = type;
if (abstract_p && (TREE_TYPE (decl) != NULL_TREE || TREE_STATIC (decl)))
@ -6640,6 +6640,34 @@ build_void_list_node (void)
return t;
}
/* Return a structure for a parameter with the given SPECS, ATTRS and
DECLARATOR. */
tree
build_c_parm (tree specs, tree attrs, tree declarator)
{
return build_tree_list (build_tree_list (specs, declarator), attrs);
}
/* Return a declarator with nested attributes. TARGET is the inner
declarator to which these attributes apply. ATTRS are the
attributes. */
tree
build_attrs_declarator (tree attrs, tree target)
{
return tree_cons (attrs, target, NULL_TREE);
}
/* Return a declarator for a function with arguments specified by ARGS
and return type specified by TARGET. */
tree
build_function_declarator (tree args, tree target)
{
return build_nt (CALL_EXPR, target, args, NULL_TREE);
}
/* Return something to represent absolute declarators containing a *.
TARGET is the absolute declarator that the * contains.
TYPE_QUALS_ATTRS is a list of modifiers such as const or volatile
@ -6656,7 +6684,7 @@ make_pointer_declarator (tree type_quals_attrs, tree target)
tree itarget = target;
split_specs_attrs (type_quals_attrs, &quals, &attrs);
if (attrs != NULL_TREE)
itarget = tree_cons (attrs, target, NULL_TREE);
itarget = build_attrs_declarator (attrs, target);
return build1 (INDIRECT_REF, quals, itarget);
}

View File

@ -1620,11 +1620,11 @@ declarator:
after_type_declarator:
'(' maybe_attribute after_type_declarator ')'
{ $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
{ $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
| after_type_declarator '(' parmlist_or_identifiers %prec '.'
{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
{ $$ = build_function_declarator ($3, $1); }
| after_type_declarator array_declarator %prec '.'
{ $$ = set_array_declarator_type ($2, $1, false); }
{ $$ = set_array_declarator_inner ($2, $1, false); }
| '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
{ $$ = make_pointer_declarator ($2, $3); }
| TYPENAME
@ -1644,9 +1644,9 @@ parm_declarator:
parm_declarator_starttypename:
parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
{ $$ = build_function_declarator ($3, $1); }
| parm_declarator_starttypename array_declarator %prec '.'
{ $$ = set_array_declarator_type ($2, $1, false); }
{ $$ = set_array_declarator_inner ($2, $1, false); }
| TYPENAME
@@ifobjc
| OBJECTNAME
@ -1655,15 +1655,15 @@ parm_declarator_starttypename:
parm_declarator_nostarttypename:
parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
{ $$ = build_function_declarator ($3, $1); }
| parm_declarator_nostarttypename array_declarator %prec '.'
{ $$ = set_array_declarator_type ($2, $1, false); }
{ $$ = set_array_declarator_inner ($2, $1, false); }
| '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
{ $$ = make_pointer_declarator ($2, $3); }
| '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
{ $$ = make_pointer_declarator ($2, $3); }
| '(' maybe_attribute parm_declarator_nostarttypename ')'
{ $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
{ $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
;
/* A declarator allowed whether or not there has been
@ -1671,13 +1671,13 @@ parm_declarator_nostarttypename:
notype_declarator:
notype_declarator '(' parmlist_or_identifiers %prec '.'
{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
{ $$ = build_function_declarator ($3, $1); }
| '(' maybe_attribute notype_declarator ')'
{ $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
{ $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
| '*' maybe_type_quals_attrs notype_declarator %prec UNARY
{ $$ = make_pointer_declarator ($2, $3); }
| notype_declarator array_declarator %prec '.'
{ $$ = set_array_declarator_type ($2, $1, false); }
{ $$ = set_array_declarator_inner ($2, $1, false); }
| IDENTIFIER
;
@ -1909,17 +1909,15 @@ absdcl: /* an absolute declarator */
absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
/* empty */
{ $$ = build_tree_list (build_tree_list (current_declspecs,
NULL_TREE),
all_prefix_attributes); }
{ $$ = build_c_parm (current_declspecs, all_prefix_attributes,
NULL_TREE); }
| absdcl1
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$1),
all_prefix_attributes); }
{ $$ = build_c_parm (current_declspecs, all_prefix_attributes,
$1); }
| absdcl1_noea attributes
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$1),
chainon ($2, all_prefix_attributes)); }
{ $$ = build_c_parm (current_declspecs,
chainon ($2, all_prefix_attributes),
$1); }
;
absdcl1: /* a nonempty absolute declarator */
@ -1942,15 +1940,15 @@ absdcl1_ea:
direct_absdcl1:
'(' maybe_attribute absdcl1 ')'
{ $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
{ $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
| direct_absdcl1 '(' parmlist
{ $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
{ $$ = build_function_declarator ($3, $1); }
| direct_absdcl1 array_declarator
{ $$ = set_array_declarator_type ($2, $1, true); }
{ $$ = set_array_declarator_inner ($2, $1, true); }
| '(' parmlist
{ $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
{ $$ = build_function_declarator ($2, NULL_TREE); }
| array_declarator
{ $$ = set_array_declarator_type ($1, NULL_TREE, true); }
{ $$ = set_array_declarator_inner ($1, NULL_TREE, true); }
;
/* The [...] part of a declarator for an array type. */
@ -2526,22 +2524,19 @@ parms:
as found in a parmlist. */
parm:
declspecs_ts setspecs parm_declarator maybe_attribute
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$3),
chainon ($4, all_prefix_attributes));
{ $$ = build_c_parm (current_declspecs,
chainon ($4, all_prefix_attributes), $3);
POP_DECLSPEC_STACK; }
| declspecs_ts setspecs notype_declarator maybe_attribute
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$3),
chainon ($4, all_prefix_attributes));
{ $$ = build_c_parm (current_declspecs,
chainon ($4, all_prefix_attributes), $3);
POP_DECLSPEC_STACK; }
| declspecs_ts setspecs absdcl_maybe_attribute
{ $$ = $3;
POP_DECLSPEC_STACK; }
| declspecs_nots setspecs notype_declarator maybe_attribute
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$3),
chainon ($4, all_prefix_attributes));
{ $$ = build_c_parm (current_declspecs,
chainon ($4, all_prefix_attributes), $3);
POP_DECLSPEC_STACK; }
| declspecs_nots setspecs absdcl_maybe_attribute
@ -2553,22 +2548,19 @@ parm:
stack. */
firstparm:
declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$3),
chainon ($4, all_prefix_attributes));
{ $$ = build_c_parm (current_declspecs,
chainon ($4, all_prefix_attributes), $3);
POP_DECLSPEC_STACK; }
| declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$3),
chainon ($4, all_prefix_attributes));
{ $$ = build_c_parm (current_declspecs,
chainon ($4, all_prefix_attributes), $3);
POP_DECLSPEC_STACK; }
| declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
{ $$ = $3;
POP_DECLSPEC_STACK; }
| declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
{ $$ = build_tree_list (build_tree_list (current_declspecs,
$3),
chainon ($4, all_prefix_attributes));
{ $$ = build_c_parm (current_declspecs,
chainon ($4, all_prefix_attributes), $3);
POP_DECLSPEC_STACK; }
| declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute

View File

@ -188,7 +188,7 @@ extern void c_push_function_context (struct function *);
extern void c_pop_function_context (struct function *);
extern void push_parm_decl (tree);
extern tree pushdecl_top_level (tree);
extern tree set_array_declarator_type (tree, tree, bool);
extern tree set_array_declarator_inner (tree, tree, bool);
extern tree builtin_function (const char *, tree, int, enum built_in_class,
const char *, tree);
extern void shadow_tag (tree);
@ -200,6 +200,9 @@ extern tree start_struct (enum tree_code, tree);
extern void store_parm_decls (void);
extern tree xref_tag (enum tree_code, tree);
extern int c_expand_decl (tree);
extern tree build_c_parm (tree, tree, tree);
extern tree build_attrs_declarator (tree, tree);
extern tree build_function_declarator (tree, tree);
extern tree make_pointer_declarator (tree, tree);
/* in c-objc-common.c */