Skip to content

Commit 25cee4f

Browse files
committed
Add full declarators case to ordering module
1 parent ee8db1d commit 25cee4f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

c/common/src/codingstandards/c/Ordering.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Ordering {
1313
/**
1414
* Holds if `e1` is sequenced before `e2` as defined by Annex C in ISO/IEC 9899:2011
1515
* This limits to expression and we do not consider the sequence points that are not amenable to modelling:
16-
* - after a full declarator as described in 6.7.6 point 3.
1716
* - before a library function returns (see 7.1.4 point 3).
1817
* - after the actions associated with each formatted I/O function conversion specifier (see 7.21.6 point 1 & 7.29.2 point 1).
1918
* - between the expr before and after a call to a comparison function,
@@ -68,6 +67,24 @@ module Ordering {
6867
// The side effect of updating the stored value of the left operand is sequenced after the value computations of the left and right operands.
6968
// See 6.5.16
7069
e2.(Assignment).getAnOperand().getAChild*() = e1
70+
or
71+
// There is a sequence point after a full declarator as described in 6.7.6 point 3.
72+
exists(DeclStmt declStmt, int i, int j | i < j |
73+
declStmt
74+
.getDeclarationEntry(i)
75+
.(VariableDeclarationEntry)
76+
.getVariable()
77+
.getInitializer()
78+
.getExpr()
79+
.getAChild*() = e1 and
80+
declStmt
81+
.getDeclarationEntry(j)
82+
.(VariableDeclarationEntry)
83+
.getVariable()
84+
.getInitializer()
85+
.getExpr()
86+
.getAChild*() = e2
87+
)
7188
)
7289
}
7390

0 commit comments

Comments
 (0)