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. */
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)))
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
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);
}
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
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
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
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
;
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 */
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. */
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
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