Debian Codegraph @

gcc/testsuite/g++.dg/abi/no_unique_address8a.C

raw
1 // { dg-do compile { target c++11 } }
2 // { dg-options "-fabi-version=18 -Wabi=19" }
3
4 #include <cstddef>
5
6 #define NOUNIQUE [[no_unique_address]]
7
8 struct Empty { };
9 #define CHECK_DISTINCT(type, field1, field2) static_assert(offsetof(type, field1) != offsetof(type, field2))
10 #define CHECK_SAME(type, field1, field2) static_assert(offsetof(type, field1) == offsetof(type, field2))
11
12 struct A1 {
13 NOUNIQUE Empty a;
14 Empty b;
15 };
16 CHECK_DISTINCT(A1, a, b);
17 struct A2 {
18 NOUNIQUE const Empty a;
19 const Empty b;
20 };
21 CHECK_DISTINCT(A2, a, b);
22 struct A3 { // { dg-warning "layout" }
23 NOUNIQUE const Empty a;
24 Empty b;
25 };
26 CHECK_SAME(A3, a, b);
27 struct A4 { // { dg-warning "layout" }
28 NOUNIQUE Empty a;
29 const Empty b;
30 };
31 CHECK_SAME(A4, a, b);