Debian Codegraph @

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

raw
1 // { dg-do compile { target c++11 } }
2 // { dg-options "-fabi-version=19 -Wabi=18" }
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
11 struct A1 {
12 NOUNIQUE Empty a;
13 Empty b;
14 };
15 CHECK_DISTINCT(A1, a, b);
16 struct A2 {
17 NOUNIQUE const Empty a;
18 const Empty b;
19 };
20 CHECK_DISTINCT(A2, a, b);
21 struct A3 { // { dg-warning "layout" }
22 NOUNIQUE const Empty a;
23 Empty b;
24 };
25 CHECK_DISTINCT(A3, a, b);
26 struct A4 { // { dg-warning "layout" }
27 NOUNIQUE Empty a;
28 const Empty b;
29 };
30 CHECK_DISTINCT(A4, a, b);