Skip to content

Commit a2086a7

Browse files
committed
[CxxInterop] use [[msvc::no_unique_address]] on Windows (NFC)
This test case used [[no_unique_address]], which is not supported on Windows. Use [[msvc::no_unique_address]] instead. Resolves #86095
1 parent f083c4b commit a2086a7

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

test/Interop/Cxx/class/Inputs/member-variables.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
#include <type_traits>
66
#include <optional>
77

8+
#if defined(_WIN32) || defined(_WIN64)
9+
#define NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
10+
#else
11+
#define NO_UNIQUE_ADDRESS [[no_unique_address]]
12+
#endif
13+
814
class MyClass {
915
public:
1016
const int const_member = 23;
@@ -17,19 +23,19 @@ struct Empty {
1723

1824
struct HasZeroSizedField {
1925
int a;
20-
[[no_unique_address]] Empty b;
26+
NO_UNIQUE_ADDRESS Empty b;
2127
short c;
22-
[[no_unique_address]] Empty d;
28+
NO_UNIQUE_ADDRESS Empty d;
2329
int* e;
24-
[[no_unique_address]] Empty f;
30+
NO_UNIQUE_ADDRESS Empty f;
2531

2632
int get_a() const { return a; }
2733
short get_c() const { return c; }
2834
void set_c(short c) { this->c = c; }
2935
};
3036

3137
struct ReuseOptionalFieldPadding {
32-
[[no_unique_address]] std::optional<int> a = {2};
38+
NO_UNIQUE_ADDRESS std::optional<int> a = {2};
3339
char c;
3440
char get_c() const { return c; }
3541
void set_c(char c) { this->c = c; }
@@ -40,7 +46,7 @@ struct ReuseOptionalFieldPadding {
4046
using OptInt = std::optional<int>;
4147

4248
struct ReuseOptionalFieldPaddingWithTypedef {
43-
[[no_unique_address]] OptInt a;
49+
NO_UNIQUE_ADDRESS OptInt a;
4450
char c;
4551
char get_c() const { return c; }
4652
void set_c(char c) { this->c = c; }
@@ -59,7 +65,7 @@ struct NonStandardLayoutClass {
5965
static_assert(std::is_standard_layout_v<NonStandardLayoutClass<int>> == false);
6066

6167
struct ReuseNonStandardLayoutFieldPadding {
62-
[[no_unique_address]] NonStandardLayoutClass<int> a;
68+
NO_UNIQUE_ADDRESS NonStandardLayoutClass<int> a;
6369
char c;
6470
char get_c() const { return c; }
6571
void set_c(char c) { this->c = c; }
@@ -69,7 +75,7 @@ struct ReuseNonStandardLayoutFieldPadding {
6975

7076
template<typename T>
7177
struct ReuseDependentFieldPadding {
72-
[[no_unique_address]] struct { private: T x; public: char pad_me; } a;
78+
NO_UNIQUE_ADDRESS struct { private: T x; public: char pad_me; } a;
7379
char c;
7480
char get_c() const { return c; }
7581
void set_c(char c) { this->c = c; }
@@ -94,7 +100,7 @@ struct EmptyNotImported {
94100

95101
struct LastFieldNoUniqueAddress {
96102
char c;
97-
[[no_unique_address]] EmptyNotImported p0;
103+
NO_UNIQUE_ADDRESS EmptyNotImported p0;
98104

99105
LastFieldNoUniqueAddress(const LastFieldNoUniqueAddress &other) {}
100106
LastFieldNoUniqueAddress(LastFieldNoUniqueAddress &&other) {}

0 commit comments

Comments
 (0)