[libcxx-commits] [libcxx] [libc++][test] Mark `UNSUPPORTED` for a test relying on `[[clang::trivial_abi]]` for compilers not supporting it (PR #211736)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 10 23:21:36 PDT 2026
https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/211736
>From 96cc0f22868c171ce4e9af95a625ab869e566517 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Fri, 24 Jul 2026 14:25:43 +0800
Subject: [PATCH 1/2] [libc++][test] Guard use of `[[clang::trivial_abi]]`
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.
---
.../sequences/vector/trivial_relocation.pass.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
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; }
>From 41668c13ef86fcdefe4c8b1a29fd29abf72a0a4e Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Tue, 11 Aug 2026 14:14:59 +0800
Subject: [PATCH 2/2] Change to `UNSUPPORTED`
---
.../sequences/vector/trivial_relocation.pass.cpp | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
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 1ac46b182f680..1dcf5b56337c8 100644
--- a/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp
@@ -6,6 +6,10 @@
//
//===----------------------------------------------------------------------===//
+// MSVC does not support [[clang::trivial_abi]], while GCC supports it only since GCC 17.
+// UNSUPPORTED: msvc
+// UNSUPPORTED: gcc-15, gcc-16
+
// <vector>
// Make sure we don't miscompile vector operations for types that shouldn't be considered
@@ -19,18 +23,11 @@
#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 TEST_CLANG_TRIVIAL_ABI Inner {
+struct [[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; }
More information about the libcxx-commits
mailing list