Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Add test for CWG190 "Layout-compatible POD-struct types" #121668

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

Endilll
Copy link
Contributor

@Endilll Endilll commented Jan 4, 2025

This patch adds test for CWG190, 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.

@Endilll Endilll added clang Clang issues not falling into any other category c++ labels Jan 4, 2025
@Endilll Endilll requested review from cor3ntin and shafik January 4, 2025 21:42
@llvmbot
Copy link
Member

llvmbot commented Jan 4, 2025

@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)

Changes

This patch adds test for CWG190, 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.


Full diff: https://github.com/llvm/llvm-project/pull/121668.diff

2 Files Affected:

  • (modified) clang/test/CXX/drs/cwg1xx.cpp (+19-2)
  • (modified) clang/www/cxx_dr_status.html (+1-1)
diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6aec8b65c91f12..939de6dee06d38 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -1314,8 +1314,25 @@ namespace cwg188 { // cwg188: yes
   static_assert(sizeof(0, c) == 10, "");
 }
 
-// cwg190 FIXME: add codegen test for tbaa
-//              or implement C++20 std::is_layout_compatible and test it this way
+namespace cwg190 { // cwg190: 19
+struct A {
+  int a;
+  static double x;
+  int b;
+  void y();
+  int c;
+};
+
+struct B {
+  int a;
+  void y();
+  int b;
+  static double x;
+  int c;
+};
+
+static_assert(__is_layout_compatible(A, B), "");
+} // namespace cwg190
 
 int cwg191_j;
 namespace cwg191 { // cwg191: yes
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..ca216272147a5f 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1185,7 +1185,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/190.html">190</a></td>
     <td>TC1</td>
     <td>Layout-compatible POD-struct types</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Clang 19</td>
   </tr>
   <tr id="191">
     <td><a href="https://cplusplus.github.io/CWG/issues/191.html">191</a></td>

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saying clang 19 is very weird as this probably always worked, but lgtm otherwise

@Endilll Endilll merged commit 267ab1c into llvm:main Jan 5, 2025
11 checks passed
@Endilll Endilll deleted the cwg190 branch January 5, 2025 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants