aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index aaa9678..4a36c54 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5272,10 +5272,13 @@ mark_forward_parm_decls (void)
literal, which may be an incomplete array type completed by the
initializer; INIT is a CONSTRUCTOR at LOC that initializes the compound
literal. NON_CONST is true if the initializers contain something
- that cannot occur in a constant expression. */
+ that cannot occur in a constant expression. If ALIGNAS_ALIGN is nonzero,
+ it is the (valid) alignment for this compound literal, as specified
+ with _Alignas. */
tree
-build_compound_literal (location_t loc, tree type, tree init, bool non_const)
+build_compound_literal (location_t loc, tree type, tree init, bool non_const,
+ unsigned int alignas_align)
{
/* We do not use start_decl here because we have a type, not a declarator;
and do not use finish_decl because the decl should be stored inside
@@ -5299,6 +5302,11 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const)
DECL_IGNORED_P (decl) = 1;
TREE_TYPE (decl) = type;
c_apply_type_quals_to_decl (TYPE_QUALS (strip_array_types (type)), decl);
+ if (alignas_align)
+ {
+ SET_DECL_ALIGN (decl, alignas_align * BITS_PER_UNIT);
+ DECL_USER_ALIGN (decl) = 1;
+ }
store_init_value (loc, decl, init, NULL_TREE);
if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))