https://github.com/woruyu created https://github.com/llvm/llvm-project/pull/180124
### Summary the related PR: https://github.com/llvm/llvm-project/pull/179177, add bits < 8 testcase for __builtin_bswapg >From 71048d3190c11fbcd18cbde5770fe3674723cf6a Mon Sep 17 00:00:00 2001 From: woruyu <[email protected]> Date: Fri, 6 Feb 2026 13:52:12 +0800 Subject: [PATCH] [test] Add bit < 8 testcase for x86 __builtin_bswapg --- clang/test/AST/ByteCode/builtin-functions.cpp | 3 +++ clang/test/Sema/constant-builtins-2.c | 2 ++ clang/test/SemaCXX/builtin-bswapg.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 10f7ff294ae00..779bb450084b3 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -851,6 +851,9 @@ namespace bswap { int h15 = __builtin_bswapg((_BitInt(24))0x1234) == (_BitInt(24))0x3412 ? 1 : f(); // expected-error@-1 {{_BitInt type '_BitInt(24)' (24 bits) must be a multiple of 16 bits for byte swapping}} // ref-error@-2 {{_BitInt type '_BitInt(24)' (24 bits) must be a multiple of 16 bits for byte swapping}} + int h16 = __builtin_bswapg((_BitInt(5))0x1) == (_BitInt(5))0x1 ? 1 : f(); + // expected-error@-1 {{_BitInt type '_BitInt(5)' (5 bits) must be a multiple of 16 bits for byte swapping}} + // ref-error@-2 {{_BitInt type '_BitInt(5)' (5 bits) must be a multiple of 16 bits for byte swapping}} #endif constexpr const int const_expr = 0x1234; diff --git a/clang/test/Sema/constant-builtins-2.c b/clang/test/Sema/constant-builtins-2.c index e875863e7fa91..3c437fcbe5e0d 100644 --- a/clang/test/Sema/constant-builtins-2.c +++ b/clang/test/Sema/constant-builtins-2.c @@ -502,6 +502,8 @@ int h21 = __builtin_bswapg((_BitInt(64))0x0000000000001234) == (_BitInt(64))0x34 int h22 = __builtin_bswapg(~(_BitInt(128))0) == (~(_BitInt(128))0) ? 1 : f(); int h23 = __builtin_bswapg((_BitInt(24))0x1234) == (_BitInt(24))0x3412 ? 1 : f(); // expected-error@-1 {{_BitInt type '_BitInt(24)' (24 bits) must be a multiple of 16 bits for byte swapping}} +int h24 = __builtin_bswapg((_BitInt(3))0x3) == (_BitInt(3))0x3 ? 1 : f(); +// expected-error@-1 {{_BitInt type '_BitInt(3)' (3 bits) must be a multiple of 16 bits for byte swapping}} extern long int bi0; extern __typeof__(__builtin_expect(0, 0)) bi0; diff --git a/clang/test/SemaCXX/builtin-bswapg.cpp b/clang/test/SemaCXX/builtin-bswapg.cpp index 815cc0085f89e..88c387d5c4004 100644 --- a/clang/test/SemaCXX/builtin-bswapg.cpp +++ b/clang/test/SemaCXX/builtin-bswapg.cpp @@ -228,4 +228,6 @@ void test_bitint() { static_assert(__builtin_bswapg(~(_BitInt(128))0) == (~(_BitInt(128))0), ""); static_assert(__builtin_bswapg((_BitInt(24))0x1234) == (_BitInt(24))0x3412, ""); // expected-error@-1 {{_BitInt type '_BitInt(24)' (24 bits) must be a multiple of 16 bits for byte swapping}} + static_assert(__builtin_bswapg((_BitInt(4))0x7) == (_BitInt(4))0x7, ""); + // expected-error@-1 {{_BitInt type '_BitInt(4)' (4 bits) must be a multiple of 16 bits for byte swapping}} } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
