forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
29 lines (24 loc) · 980 Bytes
/
test.cpp
File metadata and controls
29 lines (24 loc) · 980 Bytes
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
#define TEST 1
// globals - external linkage
int a[1]; // COMPLIANT
int x = 1;
// int a1[1 + x]; // NON_COMPLIANT - compiler checked
// int a2[x]; //NON_COMPLIANT - compiler checked
// int a3[1][x]; // NON_COMPLIANT - compiler checked
int a4[] = {1}; // COMPLIANT - size explicitly provided
// int a5[]; // NON_COMPLIANT - compiler checked
int a6[1 + 1]; // COMPLIANT - size explicitly provided
// int a7[x][1]; // NON_COMPLIANT - compiler checked
// int (*a8)[x]; // NON_COMPLIANT - compiler checked
void f(int n) {
int a1[] = {1}; // COMPLIANT - not external linkage
int a2[1]; // COMPLIANT - not external linkage
extern int e1[]; // NON_COMPLIANT
}
struct s {
// Structs must have at least one non-flexible array member.
int foo;
// static data members have external linkage - but not currently detected in
// our external linkage lib - also FAMs are not in scope for this rule
static const int flexibleArrayMember[]; // COMPLIANT
};