+2015-05-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/59012
+ * parser.c (cp_parser_std_attribute_list): Handle attribute expansion.
+ (cp_parser_std_attribute_spec): Handle alignas pack expansion.
+ * decl2.c (is_late_template_attribute): An attribute exp is dependent.
+ * pt.c (make_pack_expansion): Allow TREE_LIST for attribute expansion.
+ (apply_late_template_attributes): Handle attribute pack expansion.
+
2015-05-07 Marek Polacek <polacek@redhat.com>
PR c/65179
&& is_attribute_p ("omp declare simd", name))
return true;
+ /* An attribute pack is clearly dependent. */
+ if (args && PACK_EXPANSION_P (args))
+ return true;
+
/* If any of the arguments are dependent expressions, we can't evaluate
the attribute until instantiation time. */
for (arg = args; arg; arg = TREE_CHAIN (arg))
attributes = attribute;
}
token = cp_lexer_peek_token (parser->lexer);
+ if (token->type == CPP_ELLIPSIS)
+ {
+ cp_lexer_consume_token (parser->lexer);
+ TREE_VALUE (attribute)
+ = make_pack_expansion (TREE_VALUE (attribute));
+ token = cp_lexer_peek_token (parser->lexer);
+ }
if (token->type != CPP_COMMA)
break;
cp_lexer_consume_token (parser->lexer);
return alignas_expr;
}
+ alignas_expr = cxx_alignas_expr (alignas_expr);
+ alignas_expr = build_tree_list (NULL_TREE, alignas_expr);
+
+ if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
+ {
+ cp_lexer_consume_token (parser->lexer);
+ alignas_expr = make_pack_expansion (alignas_expr);
+ }
+
if (cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN) == NULL)
{
cp_parser_error (parser, "expected %<)%>");
return error_mark_node;
}
- alignas_expr = cxx_alignas_expr (alignas_expr);
-
/* Build the C++-11 representation of an 'aligned'
attribute. */
attributes =
build_tree_list (build_tree_list (get_identifier ("gnu"),
get_identifier ("aligned")),
- build_tree_list (NULL_TREE, alignas_expr));
+ alignas_expr);
}
return attributes;
if (!arg || arg == error_mark_node)
return arg;
- if (TREE_CODE (arg) == TREE_LIST)
+ if (TREE_CODE (arg) == TREE_LIST && TREE_PURPOSE (arg))
{
- /* The only time we will see a TREE_LIST here is for a base
+ /* A TREE_LIST with a non-null TREE_PURPOSE is for a base
class initializer. In this case, the TREE_PURPOSE will be a
_TYPE node (representing the base class expansion we're
initializing) and the TREE_VALUE will be a TREE_LIST
= tree_cons (NULL_TREE, TREE_VALUE (TREE_VALUE (t)),
chain);
}
+ else if (TREE_VALUE (t) && PACK_EXPANSION_P (TREE_VALUE (t)))
+ {
+ /* An attribute pack expansion. */
+ tree purp = TREE_PURPOSE (t);
+ tree pack = (tsubst_pack_expansion
+ (TREE_VALUE (t), args, complain, in_decl));
+ int len = TREE_VEC_LENGTH (pack);
+ for (int i = 0; i < len; ++i)
+ {
+ tree elt = TREE_VEC_ELT (pack, i);
+ *q = build_tree_list (purp, elt);
+ q = &TREE_CHAIN (*q);
+ }
+ continue;
+ }
else
TREE_VALUE (t)
= tsubst_expr (TREE_VALUE (t), args, complain, in_decl,
--- /dev/null
+// PR c++/59012
+// { dg-do compile { target c++11 } }
+// { dg-final { scan-assembler "align 8" { target x86_64-*-*-gnu } } }
+
+template <class... T>
+struct A
+{
+ alignas(T...) char t;
+};
+
+A<int,double> a;
+
+template <class... T>
+struct A2
+{
+ [[gnu::aligned (alignof (T))...]] char t;
+};
+
+A2<int,double> a2;