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
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
+23-4Lines changed: 23 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -11,16 +11,35 @@
11
11
12
12
voidnarrowing_equivalent_bitwidth() {
13
13
int i;
14
-
unsignedintj;
15
-
i = j;
14
+
unsignedintui;
15
+
i = ui;
16
16
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
17
17
// DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
18
+
19
+
float f;
20
+
i = f;
21
+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
22
+
// DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
23
+
24
+
f = i;
25
+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'int' to 'float' [cppcoreguidelines-narrowing-conversions]
26
+
// DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
27
+
28
+
longlong ll;
29
+
double d;
30
+
ll = d;
31
+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: narrowing conversion from 'double' to 'long long' [cppcoreguidelines-narrowing-conversions]
32
+
// DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
33
+
34
+
d = ll;
35
+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'long long' to 'double' [cppcoreguidelines-narrowing-conversions]
36
+
// DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
18
37
}
19
38
20
39
voidmost_narrowing_is_not_ok() {
21
40
int i;
22
-
longlongj;
23
-
i = j;
41
+
longlongui;
42
+
i = ui;
24
43
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
25
44
// CHECK-MESSAGES-DISABLED: :[[@LINE-2]]:7: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
0 commit comments