(cp_declarator *, tree, cp_cv_quals, cp_virt_specifiers, cp_ref_qualifier,
tree, tree, tree, tree, tree, location_t);
static cp_declarator *make_array_declarator
- (cp_declarator *, tree);
+ (cp_declarator *, tree, tree);
static cp_declarator *make_pointer_declarator
(cp_cv_quals, cp_declarator *, tree);
static cp_declarator *make_reference_declarator
}
/* Make a declarator for an array of BOUNDS elements, each of which is
- defined by ELEMENT. */
+ defined by ELEMENT. STD_ATTRS contains attributes that appertain to
+ the array type. */
cp_declarator *
-make_array_declarator (cp_declarator *element, tree bounds)
+make_array_declarator (cp_declarator *element, tree bounds, tree std_attrs)
{
cp_declarator *declarator;
else
declarator->parameter_pack_p = false;
+ declarator->std_attributes = std_attrs;
+
return declarator;
}
if (*nelts == error_mark_node)
*nelts = integer_one_node;
+ /* FIXME: Maybe build even the outermost array type and strip
+ it, to diagnose the attributes on it. Problem is that VLAs aren't
+ pedantically allowed except for this case. */
+ if (*nelts
+ && declarator->std_attributes
+ && any_nonignored_attribute_p (declarator->std_attributes))
+ warning (OPT_Wattributes, "attributes ignored on outermost array "
+ "type in new expression");
+
if (*nelts == NULL_TREE)
/* Leave [] in the declarator. */;
else if (outer_declarator)
/* Parse a direct-new-declarator.
direct-new-declarator:
- [ expression ]
- direct-new-declarator [constant-expression]
+ [ expression ] attribute-specifier-seq [opt]
+ direct-new-declarator [constant-expression] attribute-specifier-seq [opt]
*/
/* Look for the closing `]'. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
+ tree attrs = cp_parser_std_attribute_spec_seq (parser);
/* Add this bound to the declarator. */
- declarator = make_array_declarator (declarator, expression);
+ declarator = make_array_declarator (declarator, expression, attrs);
/* If the next token is not a `[', then there are no more
bounds. */
}
attrs = cp_parser_std_attribute_spec_seq (parser);
- declarator = make_array_declarator (declarator, bounds);
- declarator->std_attributes = attrs;
+ declarator = make_array_declarator (declarator, bounds, attrs);
}
else if (first && dcl_kind != CP_PARSER_DECLARATOR_ABSTRACT)
{