From 59787d0af77d0a45dabb06ac7fc70e9bd7a9d5d8 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@de.ibm.com>
Date: Wed, 30 Dec 2015 15:08:52 +0100
Subject: [PATCH] PR/68089: C++-11: Ingore "alignas(0)".
error message.
This is required by the C++-11 standard.
---
gcc/cp/parser.c | 15 +++++++++------
gcc/testsuite/g++.dg/cpp0x/alignas5.C | 19 +++++++++++++++++++
2 files changed, 28 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas5.C
@@ -23990,6 +23990,7 @@ cp_parser_std_attribute_spec (cp_parser *parser)
else
{
tree alignas_expr;
+ int is_int_zero;
/* Look for an alignment-specifier. */
@@ -24026,6 +24027,7 @@ cp_parser_std_attribute_spec (cp_parser *parser)
}
alignas_expr = cxx_alignas_expr (alignas_expr);
+ is_int_zero = integer_zerop (alignas_expr);
alignas_expr = build_tree_list (NULL_TREE, alignas_expr);
if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
@@ -24040,12 +24042,13 @@ cp_parser_std_attribute_spec (cp_parser *parser)
return error_mark_node;
}
- /* Build the C++-11 representation of an 'aligned'
- attribute. */
- attributes =
- build_tree_list (build_tree_list (get_identifier ("gnu"),
- get_identifier ("aligned")),
- alignas_expr);
+ if (! is_int_zero)
+ /* Build the C++-11 representation of an 'aligned'
+ attribute. */
+ attributes =
+ build_tree_list (build_tree_list (get_identifier ("gnu"),
+ get_identifier ("aligned")),
+ alignas_expr);
}
return attributes;
new file mode 100644
@@ -0,0 +1,19 @@
+// PR c++/69089
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wno-attributes" }
+
+alignas (0) int valid1;
+alignas (1 - 1) int valid2;
+struct Tvalid
+{
+ alignas (0) int i;
+ alignas (2 * 0) int j;
+}
+
+alignas (-1) int invalid1; /* { dg-error "not a positive power of 2" } */
+alignas (1 - 2) int invalid2; /* { dg-error "not a positive power of 2" } */
+struct Tinvalid
+{
+ alignas (-1) int i; /* { dg-error "not a positive power of 2" } */
+ alignas (2 * 0 - 1) int j; /* { dg-error "not a positive power of 2" } */
+};
--
2.3.0