File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
common/src/codingstandards/cpp Expand file tree Collapse file tree 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
2020import codingstandards.cpp.EncapsulatingFunctions
2121import codingstandards.cpp.BuiltInNumericTypes
2222import codingstandards.cpp.Type
23+ import codingstandards.cpp.Operator
2324
2425from Variable v , Type typeStrippedOfSpecifiers
2526where
3031 typeStrippedOfSpecifiers instanceof UnsignedCharType or
3132 typeStrippedOfSpecifiers instanceof SignedCharType
3233 ) 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
3438select 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() {
7070 volatile long l2; // NON_COMPLIANT
7171 volatile unsigned long ul2; // NON_COMPLIANT
7272 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 {
215215 }
216216}
217217
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+
218232class StructureDerefOperator extends Operator {
219233 StructureDerefOperator ( ) {
220234 hasName ( "operator->" ) and
You can’t perform that action at this time.
0 commit comments