[gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] c++: Drop alignas restriction for stack variables.
Martin Liska
marxin@gcc.gnu.org
Mon Mar 30 10:38:09 GMT 2020
https://gcc.gnu.org/g:e3b6c052b6a0569aa8f89c50db1ac376c42e41e0
commit e3b6c052b6a0569aa8f89c50db1ac376c42e41e0
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jan 29 17:16:12 2020 -0500
c++: Drop alignas restriction for stack variables.
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.
PR c++/89357
* c-attribs.c (check_cxx_fundamental_alignment_constraints): Remove.
Diff:
---
gcc/c-family/ChangeLog | 5 +++
gcc/c-family/c-attribs.c | 62 +---------------------------------
gcc/testsuite/g++.dg/cpp0x/alignas17.C | 14 ++++++++
3 files changed, 20 insertions(+), 61 deletions(-)
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 023e49ae508..b15630df41b 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-29 Jason Merrill <jason@redhat.com>
+
+ PR c++/89357
+ * c-attribs.c (check_cxx_fundamental_alignment_constraints): Remove.
+
2020-01-23 Jason Merrill <jason@redhat.com>
* c-warn.c (conversion_warning): Change -Wsign-conversion handling.
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);
+}
More information about the Gcc-cvs
mailing list