diff options
| author | Patrick Palka <ppalka@redhat.com> | 2020-11-11 14:43:39 -0500 |
|---|---|---|
| committer | Patrick Palka <ppalka@redhat.com> | 2020-11-11 14:43:38 -0500 |
| commit | 61827d5d9a5a09a8c05d5e41f95b03ebc6c43f61 (patch) | |
| tree | 01d00c1d17c121c5ee65f3f76afd5f2a44f3c59a /gcc/cp/decl.c | |
| parent | d6e5745a9a88314e27f387b2277299076862af67 (diff) | |
| download | gcc-61827d5d9a5a09a8c05d5e41f95b03ebc6c43f61.zip gcc-61827d5d9a5a09a8c05d5e41f95b03ebc6c43f61.tar.gz gcc-61827d5d9a5a09a8c05d5e41f95b03ebc6c43f61.tar.bz2 | |
c++: Correct the handling of alignof(expr) [PR88115]
We're currently neglecting to set the ALIGNOF_EXPR_STD_P flag on an
ALIGNOF_EXPR when its operand is an expression. This leads to us
handling alignof(expr) as if it were written __alignof__(expr), and
returning the preferred alignment instead of the ABI alignment. In the
testcase below, this causes the first and third static_assert to fail on
x86.
gcc/cp/ChangeLog:
PR c++/88115
* cp-tree.h (cxx_sizeof_or_alignof_expr): Add bool parameter.
* decl.c (fold_sizeof_expr): Pass false to
cxx_sizeof_or_alignof_expr.
* parser.c (cp_parser_unary_expression): Pass std_alignof to
cxx_sizeof_or_alignof_expr.
* pt.c (tsubst_copy): Pass false to cxx_sizeof_or_alignof_expr.
(tsubst_copy_and_build): Pass std_alignof to
cxx_sizeof_or_alignof_expr.
* typeck.c (cxx_alignof_expr): Add std_alignof bool parameter
and pass it to cxx_sizeof_or_alignof_type. Set ALIGNOF_EXPR_STD_P
appropriately.
(cxx_sizeof_or_alignof_expr): Add std_alignof bool parameter
and pass it to cxx_alignof_expr. Assert op is either
SIZEOF_EXPR or ALIGNOF_EXPR.
libcc1/ChangeLog:
PR c++/88115
* libcp1plugin.cc (plugin_build_unary_expr): Pass true to
cxx_sizeof_or_alignof_expr.
gcc/testsuite/ChangeLog:
PR c++/88115
* g++.dg/cpp0x/alignof6.C: New test.
Diffstat (limited to 'gcc/cp/decl.c')
| -rw-r--r-- | gcc/cp/decl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 42e704e..c52111e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10335,7 +10335,7 @@ fold_sizeof_expr (tree t) else r = cxx_sizeof_or_alignof_expr (EXPR_LOCATION (t), TREE_OPERAND (t, 0), SIZEOF_EXPR, - false); + false, false); if (r == error_mark_node) r = size_one_node; return r; |
