| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -std=c++2a %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
struct Empty {}; |
| 5 |
|
| 6 |
struct A { |
| 7 |
[[no_unique_address]] Empty e; |
| 8 |
char x; |
| 9 |
}; |
| 10 |
|
| 11 |
static_assert(__has_unique_object_representations(A)); |
| 12 |
|
| 13 |
struct B { |
| 14 |
char x; |
| 15 |
[[no_unique_address]] Empty e; |
| 16 |
}; |
| 17 |
|
| 18 |
static_assert(__has_unique_object_representations(B)); |
| 19 |
|
| 20 |
struct C { |
| 21 |
char x; |
| 22 |
[[no_unique_address]] Empty e1; |
| 23 |
[[no_unique_address]] Empty e2; |
| 24 |
}; |
| 25 |
|
| 26 |
static_assert(!__has_unique_object_representations(C)); |
| 27 |
|
| 28 |
namespace TailPaddingReuse { |
| 29 |
struct A { |
| 30 |
private: |
| 31 |
int a; |
| 32 |
|
| 33 |
public: |
| 34 |
char b; |
| 35 |
}; |
| 36 |
|
| 37 |
struct B { |
| 38 |
[[no_unique_address]] A a; |
| 39 |
char c[3]; |
| 40 |
}; |
| 41 |
} // namespace TailPaddingReuse |
| 42 |
static_assert(__has_unique_object_representations(TailPaddingReuse::B)); |