Skip to content

Commit 267ab1c

Browse files
authored
[clang] Add test for CWG190 "Layout-compatible POD-struct types" (#121668)
This patch adds test for [CWG190](https://cplusplus.github.io/CWG/issues/190.html), leveraging `__is_layout_compatible` intrinsic added for C++20 `std::is_layout_compatible`. I conservatively set the status to Clang 19, as it's the first release that implemented said intrinsic.
1 parent 0093450 commit 267ab1c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

clang/test/CXX/drs/cwg1xx.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,8 +1314,25 @@ namespace cwg188 { // cwg188: yes
13141314
static_assert(sizeof(0, c) == 10, "");
13151315
}
13161316

1317-
// cwg190 FIXME: add codegen test for tbaa
1318-
// or implement C++20 std::is_layout_compatible and test it this way
1317+
namespace cwg190 { // cwg190: 19
1318+
struct A {
1319+
int a;
1320+
static double x;
1321+
int b;
1322+
void y();
1323+
int c;
1324+
};
1325+
1326+
struct B {
1327+
int a;
1328+
void y();
1329+
int b;
1330+
static double x;
1331+
int c;
1332+
};
1333+
1334+
static_assert(__is_layout_compatible(A, B), "");
1335+
} // namespace cwg190
13191336

13201337
int cwg191_j;
13211338
namespace cwg191 { // cwg191: yes

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
11851185
<td><a href="https://cplusplus.github.io/CWG/issues/190.html">190</a></td>
11861186
<td>TC1</td>
11871187
<td>Layout-compatible POD-struct types</td>
1188-
<td class="unknown" align="center">Unknown</td>
1188+
<td class="full" align="center">Clang 19</td>
11891189
</tr>
11901190
<tr id="191">
11911191
<td><a href="https://cplusplus.github.io/CWG/issues/191.html">191</a></td>

0 commit comments

Comments
 (0)