diff options
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -64,6 +64,7 @@ typedef struct token *attr_t(struct token *, struct symbol *, static attr_t attribute_packed, attribute_aligned, attribute_modifier, attribute_address_space, attribute_context, + attribute_designated_init, attribute_transparent_union, ignore_attribute, attribute_mode, attribute_force; @@ -319,6 +320,10 @@ static struct symbol_op context_op = { .attribute = attribute_context, }; +static struct symbol_op designated_init_op = { + .attribute = attribute_designated_init, +}; + static struct symbol_op transparent_union_op = { .attribute = attribute_transparent_union, }; @@ -454,6 +459,7 @@ static struct init_keyword { { "address_space",NS_KEYWORD, .op = &address_space_op }, { "mode", NS_KEYWORD, .op = &mode_op }, { "context", NS_KEYWORD, .op = &context_op }, + { "designated_init", NS_KEYWORD, .op = &designated_init_op }, { "__transparent_union__", NS_KEYWORD, .op = &transparent_union_op }, { "noreturn", NS_KEYWORD, MOD_NORETURN, .op = &attr_mod_op }, { "__noreturn__", NS_KEYWORD, MOD_NORETURN, .op = &attr_mod_op }, @@ -1145,6 +1151,15 @@ static struct token *attribute_context(struct token *token, struct symbol *attr, return token; } +static struct token *attribute_designated_init(struct token *token, struct symbol *attr, struct decl_state *ctx) +{ + if (ctx->ctype.base_type && ctx->ctype.base_type->type == SYM_STRUCT) + ctx->ctype.base_type->designated_init = 1; + else + warning(token->pos, "attribute designated_init applied to non-structure type"); + return token; +} + static struct token *attribute_transparent_union(struct token *token, struct symbol *attr, struct decl_state *ctx) { if (Wtransparent_union) |