File tree 4 files changed +27
-2
lines changed
common/src/codingstandards/cpp
4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change
1
+ - ` A3-9-1 ` - ` VariableWidthIntegerTypesUsed.ql ` :
2
+ - Fixes #614 . Excludes post increment and decrement operators.
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import codingstandards.cpp.autosar
20
20
import codingstandards.cpp.EncapsulatingFunctions
21
21
import codingstandards.cpp.BuiltInNumericTypes
22
22
import codingstandards.cpp.Type
23
+ import codingstandards.cpp.Operator
23
24
24
25
from Variable v , Type typeStrippedOfSpecifiers
25
26
where
30
31
typeStrippedOfSpecifiers instanceof UnsignedCharType or
31
32
typeStrippedOfSpecifiers instanceof SignedCharType
32
33
) and
33
- not v instanceof ExcludedVariable
34
+ not v instanceof ExcludedVariable and
35
+ //post-increment/post-decrement operators are required by the standard to have a dummy int parameter
36
+ not v .( Parameter ) .getFunction ( ) instanceof PostIncrementOperator and
37
+ not v .( Parameter ) .getFunction ( ) instanceof PostDecrementOperator
34
38
select v , "Variable '" + v .getName ( ) + "' has variable-width type."
Original file line number Diff line number Diff line change @@ -70,4 +70,9 @@ void test_variable_width_type_qualified_variables() {
70
70
volatile long l2; // NON_COMPLIANT
71
71
volatile unsigned long ul2; // NON_COMPLIANT
72
72
volatile signed long sl2; // NON_COMPLIANT
73
- }
73
+ }
74
+
75
+ struct test_fix_fp_614 {
76
+ test_fix_fp_614 operator ++(int ); // COMPLIANT
77
+ test_fix_fp_614 operator --(int ); // COMPLIANT
78
+ };
Original file line number Diff line number Diff line change @@ -215,6 +215,20 @@ class IncrementOperator extends Operator {
215
215
}
216
216
}
217
217
218
+ class PostIncrementOperator extends Operator {
219
+ PostIncrementOperator ( ) {
220
+ hasName ( "operator++" ) and
221
+ getNumberOfParameters ( ) = 1
222
+ }
223
+ }
224
+
225
+ class PostDecrementOperator extends Operator {
226
+ PostDecrementOperator ( ) {
227
+ hasName ( "operator--" ) and
228
+ getNumberOfParameters ( ) = 1
229
+ }
230
+ }
231
+
218
232
class StructureDerefOperator extends Operator {
219
233
StructureDerefOperator ( ) {
220
234
hasName ( "operator->" ) and
You can’t perform that action at this time.
0 commit comments