summaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/has_unique_object_reps_no_unique_addr.cpp
blob: a64ca8277a1ebe1d93e7dabd97b8025a133da902 (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
39
40
41
42
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -std=c++2a %s
//  expected-no-diagnostics

struct Empty {};

struct A {
  [[no_unique_address]] Empty e;
  char x;
};

static_assert(__has_unique_object_representations(A));

struct B {
  char x;
  [[no_unique_address]] Empty e;
};

static_assert(__has_unique_object_representations(B));

struct C {
  char x;
  [[no_unique_address]] Empty e1;
  [[no_unique_address]] Empty e2;
};

static_assert(!__has_unique_object_representations(C));

namespace TailPaddingReuse {
struct A {
private:
  int a;

public:
  char b;
};

struct B {
  [[no_unique_address]] A a;
  char c[3];
};
} // namespace TailPaddingReuse
static_assert(__has_unique_object_representations(TailPaddingReuse::B));