Skip to content

Commit 23ddafa

Browse files
committed
Fix #540
1 parent 85036d5 commit 23ddafa

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A3-9-1` - `VariableWidthIntegerTypesUsed.ql`:
2+
- Reduce false positives by not considering variables from template instantiations.

cpp/autosar/src/rules/A3-9-1/VariableWidthIntegerTypesUsed.ql

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ where
3232
typeStrippedOfSpecifiers instanceof SignedCharType
3333
) and
3434
not v instanceof ExcludedVariable and
35+
// Dont consider template instantiations because instantiations with
36+
// Fixed Width Types are recorded after stripping their typedef'd type,
37+
// thereby, causing false positives (#540).
38+
not v.isFromTemplateInstantiation(_) and
3539
//post-increment/post-decrement operators are required by the standard to have a dummy int parameter
3640
not v.(Parameter).getFunction() instanceof PostIncrementOperator and
3741
not v.(Parameter).getFunction() instanceof PostDecrementOperator

cpp/autosar/test/rules/A3-9-1/test.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,15 @@ void test_variable_width_type_qualified_variables() {
7575
struct test_fix_fp_614 {
7676
test_fix_fp_614 operator++(int); // COMPLIANT
7777
test_fix_fp_614 operator--(int); // COMPLIANT
78-
};
78+
};
79+
80+
// COMPLIANT - instantiated with Fixed Width Types.
81+
template <typename MyType> constexpr void test_fix_fp_540(MyType value) {
82+
value++;
83+
}
84+
85+
int call_test_fix_fp_540() {
86+
test_fix_fp_540<std::uint8_t>(19);
87+
test_fix_fp_540<std::int16_t>(20);
88+
return 0;
89+
}

0 commit comments

Comments
 (0)