File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
autosar/test/rules/M5-0-3
common/src/codingstandards/cpp Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 22| test.cpp:12:8:12:14 | ... + ... | Implicit conversion converts cvalue $@ from signed char to signed short. | test.cpp:12:8:12:14 | ... + ... | expression |
33| test.cpp:14:8:14:13 | ... + ... | Implicit conversion converts cvalue $@ from signed short to signed int. | test.cpp:14:8:14:13 | ... + ... | expression |
44| 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() {
2222 std::int8_t l1;
2323 int16_arg (l1 + l1); // NON_COMPLIANT
2424 int16_arg (static_cast <std::int16_t >(l1 + l1)); // COMPLIANT
25+ int16_arg (static_cast <std::int8_t >(l1 + l1)); // NON_COMPLIANT
2526}
2627
2728std::int16_t test_return (int test) {
2829 std::int8_t l1;
2930 if (test > 0 ) {
3031 return l1 + l1; // NON_COMPLIANT
32+ } else if (test < 0 ) {
33+ return static_cast <std::int8_t >(l1 + l1); // NON_COMPLIANT
3134 } else {
3235 return static_cast <std::int16_t >(l1 + l1); // COMPLIANT
3336 }
Original file line number Diff line number Diff line change @@ -148,17 +148,9 @@ module MisraExpr {
148148 private predicate isCValue ( Expr e ) {
149149 not e .isConstant ( ) and
150150 (
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 ( ) )
156152 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 ( ) )
162154 )
163155 or
164156 isCValue ( e .( ParenthesisExpr ) .getExpr ( ) )
You can’t perform that action at this time.
0 commit comments