-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathDeclaringAFlexibleArrayMember.ql
More file actions
31 lines (29 loc) · 1.04 KB
/
DeclaringAFlexibleArrayMember.ql
File metadata and controls
31 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* @id c/cert/declaring-a-flexible-array-member
* @name DCL38-C: Use the correct syntax when declaring a flexible array member
* @description Structures with flexible array members can be declared in ways that will lead to
* undefined behaviour.
* @kind problem
* @precision very-high
* @problem.severity error
* @tags external/cert/id/dcl38-c
* correctness
* maintainability
* readability
* external/cert/severity/low
* external/cert/likelihood/unlikely
* external/cert/remediation-cost/low
* external/cert/priority/p3
* external/cert/level/l3
* external/cert/obligation/rule
*/
import cpp
import codingstandards.c.cert
import codingstandards.c.Variable
from VariableDeclarationEntry m, ArrayType a
where
not isExcluded(m, Declarations2Package::declaringAFlexibleArrayMemberQuery()) and
m.getType() = a and
m.getVariable() instanceof FlexibleArrayMemberCandidate and
a.getArraySize() = 1
select m, "Incorrect syntax used for declaring this flexible array member."