Skip to content

Commit f10cee9

Browse files
committed
[clang-tidy] Fix test failing on 32-bit architectures due to missing __int128_t
This was caused by ff60af9. The reason for the failure is that the type `__int128_t` is not available on 32-bit architectures. So just exclude the test case if 128-bit integers are not available.
1 parent 7370a48 commit f10cee9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ int Foo() { int A[T]; return sizeof(T); }
172172
template <typename T>
173173
int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
174174
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
175-
template <__int128_t N>
176-
bool Baz() { return sizeof(A) < N; }
177-
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 'sizeof(expr)' to a constant
178-
int Test3() { return Foo<42>() + Bar<char>() + Baz<-1>(); }
175+
int Test3() { return Foo<42>() + Bar<char>(); }
179176

180177
static const char* kABC = "abc";
181178
static const wchar_t* kDEF = L"def";
@@ -289,6 +286,13 @@ int Test6() {
289286
return sum;
290287
}
291288

289+
#ifdef __SIZEOF_INT128__
290+
template <__int128_t N>
291+
bool Baz() { return sizeof(A) < N; }
292+
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 'sizeof(expr)' to a constant
293+
bool Test7() { return Baz<-1>(); }
294+
#endif
295+
292296
int ValidExpressions() {
293297
int A[] = {1, 2, 3, 4};
294298
static const char str[] = "hello";

0 commit comments

Comments
 (0)