aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/abi/no_unique_address1.C
blob: 853726dd4b0cf609d3a8f0ea612a731dc50317f5 (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
31
32
33
34
35
36
37
38
// { dg-do run { target c++2a } }

struct B { };

struct A
{
  [[no_unique_address]] B b;
  int i;
};

struct C
{
  B b;
  int i;
};

struct D: B { };

struct E
{
  B b [[no_unique_address]];
  D d [[no_unique_address]];
};

constexpr bool same (void *x, void *y) { return x == y; }

int main()
{
  A a;
  if (!same(&a.b, &a.i))
    __builtin_abort();
  C c;
  if (same(&c.b, &c.i))
    __builtin_abort();
  E e;
  if (same (&e.b, &e.d))
    __builtin_abort();
}