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
+
int global_int = 42;
5
+
// 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]
6
+
7
+
short global_short = 10;
8
+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
9
+
10
+
long global_long = 100L;
11
+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
12
+
13
+
longlong global_long_long = 1000LL;
14
+
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: avoid using platform-dependent fundamental integer type 'long long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
15
+
16
+
unsignedint global_unsigned_int = 42U;
17
+
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: avoid using platform-dependent fundamental integer type 'unsigned int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
18
+
19
+
unsignedshort global_unsigned_short = 10U;
20
+
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: avoid using platform-dependent fundamental integer type 'unsigned short'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
21
+
22
+
unsignedlong global_unsigned_long = 100UL;
23
+
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: avoid using platform-dependent fundamental integer type 'unsigned long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: avoid using platform-dependent fundamental integer type 'unsigned long long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
27
+
28
+
// Test semantic types that should NOT trigger warnings
29
+
char global_char = 'a';
30
+
signedchar global_signed_char = 'b';
31
+
unsignedchar global_unsigned_char = 'c';
32
+
bool global_bool = true;
33
+
wchar_t global_wchar = L'w';
34
+
35
+
// Test function parameters
36
+
voidfunction_with_int_param(int param) {
37
+
// 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]
38
+
}
39
+
40
+
voidfunction_with_short_param(short param) {
41
+
// CHECK-MESSAGES: :[[@LINE-1]]:38: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
42
+
}
43
+
44
+
// Test function return types
45
+
intfunction_returning_int() {
46
+
// 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]
47
+
return42;
48
+
}
49
+
50
+
longfunction_returning_long() {
51
+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
52
+
return100L;
53
+
}
54
+
55
+
// Test local variables
56
+
voidtest_local_variables() {
57
+
int local_int = 10;
58
+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
59
+
60
+
short local_short = 5;
61
+
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
62
+
63
+
unsignedlong local_unsigned_long = 200UL;
64
+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: avoid using platform-dependent fundamental integer type 'unsigned long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
65
+
66
+
// These should not trigger warnings
67
+
char local_char = 'x';
68
+
bool local_bool = false;
69
+
}
70
+
71
+
// Test struct/class members
72
+
structTestStruct {
73
+
int member_int;
74
+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
75
+
76
+
long member_long;
77
+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid using platform-dependent fundamental integer type 'long'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
78
+
79
+
// These should not trigger warnings
80
+
char member_char;
81
+
bool member_bool;
82
+
};
83
+
84
+
classTestClass {
85
+
public:
86
+
unsignedint public_member;
87
+
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: avoid using platform-dependent fundamental integer type 'unsigned int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
88
+
89
+
private:
90
+
short private_member;
91
+
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: avoid using platform-dependent fundamental integer type 'short'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
92
+
};
93
+
94
+
// Test typedefs and type aliases
95
+
typedefint MyInt;
96
+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: avoid using platform-dependent fundamental integer type 'int'; consider using a typedef or fixed-width type instead [modernize-avoid-fundamental-integer-types]
97
+
98
+
using MyLong = long;
99
+
// 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
+
101
+
// Test template parameters
102
+
template<typename T>
103
+
voidtemplate_function(T param) {}
104
+
105
+
template<>
106
+
void template_function<int>(int param) {
107
+
// 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