aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/abi/no_unique_address8.C
blob: 6aa2bba7810ccc2d794aa5192e8bafea756bc52e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// { dg-do compile { target c++11 } }
// { dg-options "-fabi-version=19 -Wabi=18" }

#include <cstddef>

#define NOUNIQUE [[no_unique_address]]

struct Empty { };
#define CHECK_DISTINCT(type, field1, field2) static_assert(offsetof(type, field1) != offsetof(type, field2))

struct A1 {
    NOUNIQUE Empty a;
    Empty b;
};
CHECK_DISTINCT(A1, a, b);
struct A2 {
    NOUNIQUE const Empty a;
    const Empty b;
};
CHECK_DISTINCT(A2, a, b);
struct A3 {			// { dg-warning "layout" }
    NOUNIQUE const Empty a;
    Empty b;
};
CHECK_DISTINCT(A3, a, b);
struct A4 {			// { dg-warning "layout" }
    NOUNIQUE Empty a;
    const Empty b;
};
CHECK_DISTINCT(A4, a, b);