Since expand_stack_vars and such know how to deal with variables aligned
beyond MAX_SUPPORTED_STACK_ALIGNMENT, we shouldn't reject alignas of large
alignments. And if we don't do that, there's no point in having
check_cxx_fundamental_alignment_constraints at all, since
check_user_alignment already enforces MAX_OFILE_ALIGNMENT.
Tested x86_64-pc-linux-gnu, applying to trunk.
PR c++/89357
* c-attribs.c (check_cxx_fundamental_alignment_constraints): Remove.
---
gcc/c-family/c-attribs.c | 62 +-------------------------
gcc/testsuite/g++.dg/cpp0x/alignas17.C | 14 ++++++
2 files changed, 15 insertions(+), 61 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas17.C
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index dc9579c5c60..7ec6fc848ac 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -1957,65 +1957,6 @@ fail:
return res;
}
-/* If in c++-11, check if the c++-11 alignment constraint with respect
- to fundamental alignment (in [dcl.align]) are satisfied. If not in
- c++-11 mode, does nothing.
-
- [dcl.align]2/ says:
-
- [* if the constant expression evaluates to a fundamental alignment,
- the alignment requirement of the declared entity shall be the
- specified fundamental alignment.
-
- * if the constant expression evaluates to an extended alignment
- and the implementation supports that alignment in the context
- of the declaration, the alignment of the declared entity shall
- be that alignment
-
- * if the constant expression evaluates to an extended alignment
- and the implementation does not support that alignment in the
- context of the declaration, the program is ill-formed]. */
-
-static bool
-check_cxx_fundamental_alignment_constraints (tree node,
- unsigned align_log,
- int flags)
-{
- bool alignment_too_large_p = false;
- unsigned requested_alignment = (1U << align_log) * BITS_PER_UNIT;
- unsigned max_align = 0;
-
- if ((!(flags & ATTR_FLAG_CXX11) && !warn_cxx_compat)
- || (node == NULL_TREE || node == error_mark_node))
- return true;
-
- if (cxx_fundamental_alignment_p (requested_alignment))
- return true;
-
- if (VAR_P (node))
- {
- if (TREE_STATIC (node) || DECL_EXTERNAL (node))
- /* For file scope variables and static members, the target supports
- alignments that are at most MAX_OFILE_ALIGNMENT. */
- max_align = MAX_OFILE_ALIGNMENT;
- else
- /* For stack variables, the target supports at most
- MAX_STACK_ALIGNMENT. */
- max_align = MAX_STACK_ALIGNMENT;
- if (requested_alignment > max_align)
- alignment_too_large_p = true;
- }
- /* Let's be liberal for types and fields; don't limit their alignment any
- more than check_user_alignment already did. */
-
- if (alignment_too_large_p)
- pedwarn (input_location, OPT_Wattributes,
- "requested alignment %d is larger than %d",
- requested_alignment / BITS_PER_UNIT, max_align / BITS_PER_UNIT);
-
- return !alignment_too_large_p;
-}
-
/* Common codes shared by handle_warn_if_not_aligned_attribute and
handle_aligned_attribute. */
@@ -2059,8 +2000,7 @@ common_handle_aligned_attribute (tree *node, tree name,
tree args, int flags,
/* Log2 of specified alignment. */
int pow2align = check_user_alignment (align_expr, objfile,
/* warn_zero = */ true);
- if (pow2align == -1
- || !check_cxx_fundamental_alignment_constraints (*node, pow2align,
flags))
+ if (pow2align == -1)
{
*no_add_attrs = true;
return NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas17.C
b/gcc/testsuite/g++.dg/cpp0x/alignas17.C
new file mode 100644
index 00000000000..b736083affc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alignas17.C
@@ -0,0 +1,14 @@
+// PR c++/89357
+// { dg-do compile { target c++11 } }
+
+void g(int &);
+
+void f0() {
+ __attribute__((aligned(128))) static int x;
+ g(x);
+}
+
+void f1() {
+ alignas(128) int x;
+ g(x);
+}
base-commit: 245e40af4fab5b7cf40fb310591a879355775971
--
2.18.1