File tree 3 files changed +8
-11
lines changed
autosar/test/rules/M5-0-3
common/src/codingstandards/cpp
3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 2
2
| test.cpp:12:8:12:14 | ... + ... | Implicit conversion converts cvalue $@ from signed char to signed short. | test.cpp:12:8:12:14 | ... + ... | expression |
3
3
| test.cpp:14:8:14:13 | ... + ... | Implicit conversion converts cvalue $@ from signed short to signed int. | test.cpp:14:8:14:13 | ... + ... | expression |
4
4
| test.cpp:23:13:23:19 | (int16_t)... | Implicit conversion converts cvalue $@ from signed char to signed short. | test.cpp:23:13:23:19 | ... + ... | expression |
5
- | test.cpp:30:12:30:18 | (int16_t)... | Implicit conversion converts cvalue $@ from signed char to signed short. | test.cpp:30:12:30:18 | ... + ... | expression |
5
+ | test.cpp:25:13:25:45 | (int16_t)... | Implicit conversion converts cvalue $@ from signed char to signed short. | test.cpp:25:13:25:45 | static_cast<int8_t>... | expression |
6
+ | test.cpp:31:12:31:18 | (int16_t)... | Implicit conversion converts cvalue $@ from signed char to signed short. | test.cpp:31:12:31:18 | ... + ... | expression |
7
+ | test.cpp:33:12:33:44 | (int16_t)... | Implicit conversion converts cvalue $@ from signed char to signed short. | test.cpp:33:12:33:44 | static_cast<int8_t>... | expression |
Original file line number Diff line number Diff line change @@ -22,12 +22,15 @@ void test_func_call() {
22
22
std::int8_t l1;
23
23
int16_arg (l1 + l1); // NON_COMPLIANT
24
24
int16_arg (static_cast <std::int16_t >(l1 + l1)); // COMPLIANT
25
+ int16_arg (static_cast <std::int8_t >(l1 + l1)); // NON_COMPLIANT
25
26
}
26
27
27
28
std::int16_t test_return (int test) {
28
29
std::int8_t l1;
29
30
if (test > 0 ) {
30
31
return l1 + l1; // NON_COMPLIANT
32
+ } else if (test < 0 ) {
33
+ return static_cast <std::int8_t >(l1 + l1); // NON_COMPLIANT
31
34
} else {
32
35
return static_cast <std::int16_t >(l1 + l1); // COMPLIANT
33
36
}
Original file line number Diff line number Diff line change @@ -148,17 +148,9 @@ module MisraExpr {
148
148
private predicate isCValue ( Expr e ) {
149
149
not e .isConstant ( ) and
150
150
(
151
- exists ( ReturnStmt return |
152
- e = return .getExpr ( ) and
153
- // Only return statements which are not explicitly casted are considered
154
- not exists ( Cast c | not c .isImplicit ( ) and c .getExpr ( ) = e )
155
- )
151
+ exists ( ReturnStmt return | e = return .getExpr ( ) .getExplicitlyConverted ( ) )
156
152
or
157
- exists ( FunctionCall call |
158
- e = call .getAnArgument ( ) and
159
- // // Only function arguments which are not explicitly casted are considered
160
- not exists ( Cast c | not c .isImplicit ( ) and c .getExpr ( ) = e )
161
- )
153
+ exists ( FunctionCall call | e = call .getAnArgument ( ) .getExplicitlyConverted ( ) )
162
154
)
163
155
or
164
156
isCValue ( e .( ParenthesisExpr ) .getExpr ( ) )
You can’t perform that action at this time.
0 commit comments