Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d0bb29

Browse files
committed
Rule 7.0.1: Expand test case to cover non_compliant cases
For bool to class conversions.
1 parent0b9e2cb commit8d0bb29

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed
Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
| test.cpp:23:7:23:8 | b1 | Conversion from 'bool' to 'int'. |
2-
| test.cpp:23:12:23:13 | b2 | Conversion from 'bool' to 'int'. |
31
| test.cpp:25:7:25:8 | b1 | Conversion from 'bool' to 'int'. |
42
| test.cpp:25:12:25:13 | b2 | Conversion from 'bool' to 'int'. |
53
| test.cpp:27:7:27:8 | b1 | Conversion from 'bool' to 'int'. |
64
| test.cpp:27:12:27:13 | b2 | Conversion from 'bool' to 'int'. |
7-
| test.cpp:29:8:29:9 | b1 | Conversion from 'bool' to 'int'. |
8-
| test.cpp:33:7:33:8 |b1 | Conversion from 'bool' to 'int'. |
9-
| test.cpp:33:12:33:13 |b2 | Conversion from 'bool' to 'int'. |
5+
| test.cpp:29:7:29:8 | b1 | Conversion from 'bool' to 'int'. |
6+
| test.cpp:29:12:29:13 |b2 | Conversion from 'bool' to 'int'. |
7+
| test.cpp:31:8:31:9 |b1 | Conversion from 'bool' to 'int'. |
108
| test.cpp:35:7:35:8 | b1 | Conversion from 'bool' to 'int'. |
119
| test.cpp:35:12:35:13 | b2 | Conversion from 'bool' to 'int'. |
1210
| test.cpp:37:7:37:8 | b1 | Conversion from 'bool' to 'int'. |
13-
| test.cpp:37:13:37:14 | b2 | Conversion from 'bool' to 'int'. |
11+
| test.cpp:37:12:37:13 | b2 | Conversion from 'bool' to 'int'. |
1412
| test.cpp:39:7:39:8 | b1 | Conversion from 'bool' to 'int'. |
1513
| test.cpp:39:13:39:14 | b2 | Conversion from 'bool' to 'int'. |
16-
| test.cpp:43:7:43:8 | b1 | Conversion from 'bool' to 'int'. |
14+
| test.cpp:41:7:41:8 | b1 | Conversion from 'bool' to 'int'. |
15+
| test.cpp:41:13:41:14 | b2 | Conversion from 'bool' to 'int'. |
1716
| test.cpp:45:7:45:8 | b1 | Conversion from 'bool' to 'int'. |
1817
| test.cpp:47:7:47:8 | b1 | Conversion from 'bool' to 'int'. |
19-
| test.cpp:51:20:51:21 | b1 | Conversion from 'bool' to 'double'. |
20-
| test.cpp:52:20:52:21 | b1 | Conversion from 'bool' to 'double'. |
21-
| test.cpp:53:28:53:29 | b1 | Conversion from 'bool' to 'int'. |
22-
| test.cpp:56:34:56:35 | b1 | Conversion from 'bool' to 'int8_t'. |
23-
| test.cpp:57:36:57:37 | b1 | Conversion from 'bool' to 'int32_t'. |
24-
| test.cpp:60:6:60:7 | b1 | Conversion from 'bool' to 'int32_t'. |
25-
| test.cpp:61:6:61:7 | b1 | Conversion from 'bool' to 'double'. |
26-
| test.cpp:64:11:64:12 | b1 | Conversion from 'bool' to 'int'. |
27-
| test.cpp:72:9:72:10 | b1 | Conversion from 'bool' to 'int8_t'. |
28-
| test.cpp:73:10:73:11 | b1 | Conversion from 'bool' to 'int32_t'. |
29-
| test.cpp:74:8:74:9 | b1 | Conversion from 'bool' to 'double'. |
18+
| test.cpp:49:7:49:8 | b1 | Conversion from 'bool' to 'int'. |
19+
| test.cpp:53:20:53:21 | b1 | Conversion from 'bool' to 'double'. |
20+
| test.cpp:54:20:54:21 | b1 | Conversion from 'bool' to 'double'. |
21+
| test.cpp:55:28:55:29 | b1 | Conversion from 'bool' to 'int'. |
22+
| test.cpp:58:34:58:35 | b1 | Conversion from 'bool' to 'int8_t'. |
23+
| test.cpp:59:36:59:37 | b1 | Conversion from 'bool' to 'int32_t'. |
24+
| test.cpp:62:6:62:7 | b1 | Conversion from 'bool' to 'int32_t'. |
25+
| test.cpp:63:6:63:7 | b1 | Conversion from 'bool' to 'double'. |
26+
| test.cpp:66:11:66:12 | b1 | Conversion from 'bool' to 'int'. |
27+
| test.cpp:74:9:74:10 | b1 | Conversion from 'bool' to 'int8_t'. |
28+
| test.cpp:75:10:75:11 | b1 | Conversion from 'bool' to 'int32_t'. |
29+
| test.cpp:76:8:76:9 | b1 | Conversion from 'bool' to 'double'. |
30+
| test.cpp:113:33:113:36 | 1 | Conversion from 'bool' to 'A *'. |
31+
| test.cpp:116:8:116:11 | 1 | Conversion from 'bool' to 'int'. |
32+
| test.cpp:117:8:117:12 | 0 | Conversion from 'bool' to 'int'. |
33+
| test.cpp:118:25:118:28 | 1 | Conversion from 'bool' to 'int'. |

‎cpp/misra/test/rules/RULE-7-0-1/test.cpp‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
structA {
44
explicitA(bool) {}
55
};
6-
6+
structB {
7+
B(int) {}
8+
};
79
structBitField {
810
std::uint8_t bit :1;
911
};
@@ -105,12 +107,18 @@ void test_bool_conversion_compliant() {
105107
f1(b1 ?1 :0);// COMPLIANT
106108

107109
// Explicit constructor calls - compliant
108-
A l1{true};// COMPLIANT
109-
Al2(false);// COMPLIANT
110-
A l3 =static_cast<A>(true);// COMPLIANT
110+
A l1{true};// COMPLIANT
111+
Al2(false);// COMPLIANT
112+
A l3 =static_cast<A>(true);// COMPLIANT
113+
A *l4 =reinterpret_cast<A *>(true);// NON_COMPLIANT - converted to integer
114+
// then pointer, does not
115+
// use constructor.
116+
B l5{true};// NON_COMPLIANT
117+
Bl6(false);// NON_COMPLIANT
118+
B l7 =static_cast<B>(true);// NON_COMPLIANT
111119

112120
// Assignment to constructor - compliant
113-
Al4 = A{false};// COMPLIANT
121+
Al8 = A{false};// COMPLIANT
114122

115123
// Bit-field assignment exception - compliant
116124
bf.bit = b1;// COMPLIANT

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp