Debian Codegraph @

gcc/testsuite/g++.dg/pr53037-1.C

raw
1 /* PR c/53037. */
2 /* { dg-do compile } */
3 /* { dg-options "-O0" } */
4
5 typedef unsigned long long __u64
6 __attribute__((aligned(4),warn_if_not_aligned(8)));
7
8 struct foo1 /* { dg-warning "alignment 4 of 'foo1' is less than 8" } */
9 {
10 int i1;
11 int i2;
12 int i3;
13 __u64 x; /* { dg-warning "'foo1::x' offset 12 in 'foo1' isn't aligned to 8" } */
14 };
15
16 struct foo2
17 {
18 int i1;
19 int i2;
20 int i3;
21 __u64 x; /* { dg-warning "'foo2::x' offset 12 in 'foo2' isn't aligned to 8" } */
22 } __attribute__((aligned(8)));
23
24 struct foo3 /* { dg-warning "alignment 4 of 'foo3' is less than 8" } */
25 {
26 int i1;
27 int i3;
28 __u64 x;
29 };
30
31 struct foo4
32 {
33 int i1;
34 int i2;
35 __u64 x;
36 } __attribute__((aligned(8)));
37
38 struct foo5 /* { dg-warning "alignment \[0-9\]+ of 'foo5' is less than 16" } */
39 {
40 int i1;
41 int x __attribute__((warn_if_not_aligned(16))); /* { dg-warning "'foo5::x' offset 4 in 'foo5' isn't aligned to 16" } */
42 };
43
44 struct foo6
45 {
46 int i1;
47 int x __attribute__((warn_if_not_aligned(16))); /* { dg-warning "'foo6::x' offset 4 in 'foo6' isn't aligned to 16" } */
48 } __attribute__((aligned(16)));
49
50 struct foo7
51 {
52 int i1;
53 int i2;
54 int i3;
55 int i4;
56 int x __attribute__((warn_if_not_aligned(16)));
57 } __attribute__((aligned(16)));
58
59 union bar1 /* { dg-warning "alignment 4 of 'bar1' is less than 8" } */
60 {
61 int i1;
62 __u64 x;
63 };
64
65 union bar2
66 {
67 int i1;
68 __u64 x;
69 } __attribute__((aligned(8)));
70
71 union bar3 /* { dg-warning "alignment \[0-9\]+ of 'bar3' is less than 16" } */
72 {
73 int i1;
74 int x __attribute__((warn_if_not_aligned(16)));
75 };
76
77 union bar4
78 {
79 int i1;
80 int x __attribute__((warn_if_not_aligned(16)));
81 } __attribute__((aligned(16)));