[libcxx-commits] [libcxx] [libc++][test] Guard use of `[[clang::trivial_abi]]` (PR #211736)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 23 23:27:52 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

<details>
<summary>Changes</summary>

This patch makes `[[clang::trivial_abi]]` used only if supported to address MSVC's warning C5030.

The `TEST_CLANG_TRIVIAL_ABI` macro is not promoted to `test_macros.h` because it is currently used only in one file. We may promote it later.

Fixes #<!-- -->182392.

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


1 Files Affected:

- (modified) libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp (+8-1) 


``````````diff
diff --git a/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp b/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
index fbd597d07d6e3..1ac46b182f680 100644
--- a/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
@@ -19,11 +19,18 @@
 
 #include "test_macros.h"
 
+// The test should pass regardless of whether the compiler supports [[clang::trivial_abi]].
+#if __has_cpp_attribute(clang::trivial_abi)
+#  define TEST_CLANG_TRIVIAL_ABI [[clang::trivial_abi]]
+#else
+#  define TEST_CLANG_TRIVIAL_ABI
+#endif
+
 struct Tracker {
   std::size_t move_constructs = 0;
 };
 
-struct [[clang::trivial_abi]] Inner {
+struct TEST_CLANG_TRIVIAL_ABI Inner {
   TEST_CONSTEXPR_CXX20 explicit Inner(Tracker* tracker) : tracker_(tracker) {}
   TEST_CONSTEXPR_CXX20 Inner(const Inner& rhs) : tracker_(rhs.tracker_) { tracker_->move_constructs += 1; }
   TEST_CONSTEXPR_CXX20 Inner(Inner&& rhs) : tracker_(rhs.tracker_) { tracker_->move_constructs += 1; }

``````````

</details>


https://github.com/llvm/llvm-project/pull/211736


More information about the libcxx-commits mailing list