aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr83844.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-01-16 16:08:32 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-01-16 16:08:32 +0100
commit38943500babbfda935c1108a16ecbb03cb1a33e8 (patch)
tree8c56b282c07c85b373c44f431ced983c5995758c /gcc/testsuite/gcc.dg/pr83844.c
parent42b394ff00b100d2c968db6478c87a259333ccec (diff)
downloadgcc-38943500babbfda935c1108a16ecbb03cb1a33e8.zip
gcc-38943500babbfda935c1108a16ecbb03cb1a33e8.tar.gz
gcc-38943500babbfda935c1108a16ecbb03cb1a33e8.tar.bz2
re PR c/83844 (ICE with warn_if_not_aligned attribute)
PR c/83844 * stor-layout.c (handle_warn_if_not_align): Use byte_position and multiple_of_p instead of unchecked tree_to_uhwi and UHWI check. If off is not INTEGER_CST, issue a may not be aligned warning rather than isn't aligned. Use isn%'t rather than isn't. * fold-const.c (multiple_of_p) <case BIT_AND_EXPR>: Don't fall through into MULT_EXPR. <case MULT_EXPR>: Improve the case when bottom and one of the MULT_EXPR operands are INTEGER_CSTs and bottom is multiple of that operand, in that case check if the other operand is multiple of bottom divided by the INTEGER_CST operand. * gcc.dg/pr83844.c: New test. From-SVN: r256745
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr83844.c')
-rw-r--r--gcc/testsuite/gcc.dg/pr83844.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr83844.c b/gcc/testsuite/gcc.dg/pr83844.c
new file mode 100644
index 0000000..c6db68a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83844.c
@@ -0,0 +1,36 @@
+/* PR c/83844 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -Wall" } */
+
+typedef unsigned long long __u64 __attribute__((aligned(4),warn_if_not_aligned(8)));
+void bar (void *, void *, void *);
+
+void
+foo (int n)
+{
+ struct A
+ {
+ int i1;
+ int i2;
+ int i3[n];
+ __u64 x; /* { dg-warning "in 'struct A' may not be aligned to 8" } */
+ } __attribute__((aligned (8)));
+ struct B
+ {
+ int i1;
+ int i2;
+ long long i3[n];
+ __u64 x;
+ } __attribute__((aligned (8)));
+ struct C
+ {
+ int i1;
+ int i2;
+ int i3[2 * n];
+ __u64 x;
+ } __attribute__((aligned (8)));
+ struct A a;
+ struct B b;
+ struct C c;
+ bar (&a, &b, &c);
+}