You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Test fundamental integer types that should trigger warnings
4
16
int global_int = 42;
5
17
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
// Test fixed-width types that should NOT trigger warnings
48
+
uint32_t global_uint32 = 42U;
49
+
int32_t global_int32 = 42;
50
+
uint64_t global_uint64 = 100ULL;
51
+
int64_t global_int64 = 100LL;
52
+
53
+
// Test semantic standard library types that should NOT trigger warnings
54
+
size_t global_size = 100;
55
+
ptrdiff_t global_ptrdiff = 50;
56
+
35
57
// Test function parameters
36
58
voidfunction_with_int_param(int param) {
37
59
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
@@ -66,6 +88,14 @@ void test_local_variables() {
66
88
// These should not trigger warnings
67
89
char local_char = 'x';
68
90
bool local_bool = false;
91
+
92
+
// Fixed-width types should not trigger warnings
93
+
uint32_t local_uint32 = 42U;
94
+
int64_t local_int64 = 100LL;
95
+
96
+
// Standard library semantic types should not trigger warnings
97
+
size_t local_size = 200;
98
+
ptrdiff_t local_ptrdiff = 10;
69
99
}
70
100
71
101
// Test struct/class members
@@ -98,11 +128,14 @@ typedef int MyInt;
98
128
using MyLong = long;
99
129
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
100
130
131
+
typedeflonglong customType;
132
+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: avoid using platform-dependent fundamental integer type 'long long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
133
+
101
134
// Test template parameters
102
135
template<typename T>
103
136
voidtemplate_function(T param) {}
104
137
105
138
template<>
106
139
void template_function<int>(int param) {
107
140
// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
0 commit comments