Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d7117e8

Browse filesBrowse files
authored
Merge pull request #625 from knewbury01/knewbury01/fix-614
A3-9-1: exclude fps on post increment and decrement operators
2 parents 3e98b67 + 8cd6df7 commit d7117e8
Copy full SHA for d7117e8

File tree

Expand file treeCollapse file tree

4 files changed

+27
-2
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+27
-2
lines changed
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A3-9-1` - `VariableWidthIntegerTypesUsed.ql`:
2+
- Fixes #614. Excludes post increment and decrement operators.

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

Copy file name to clipboardExpand all lines: cpp/autosar/src/rules/A3-9-1/VariableWidthIntegerTypesUsed.ql
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import codingstandards.cpp.autosar
2020
import codingstandards.cpp.EncapsulatingFunctions
2121
import codingstandards.cpp.BuiltInNumericTypes
2222
import codingstandards.cpp.Type
23+
import codingstandards.cpp.Operator
2324

2425
from Variable v, Type typeStrippedOfSpecifiers
2526
where
@@ -30,5 +31,8 @@ where
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
3438
select v, "Variable '" + v.getName() + "' has variable-width type."

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

Copy file name to clipboardExpand all lines: cpp/autosar/test/rules/A3-9-1/test.cpp
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
};

‎cpp/common/src/codingstandards/cpp/Operator.qll

Copy file name to clipboardExpand all lines: cpp/common/src/codingstandards/cpp/Operator.qll
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
218232
class StructureDerefOperator extends Operator {
219233
StructureDerefOperator() {
220234
hasName("operator->") and

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.