forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
42 lines (33 loc) · 989 Bytes
/
test.cpp
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
32
33
34
35
36
37
38
39
40
41
42
#include "test.hpp"
int g1; // NON_COMPLIANT
extern int g2; // NON_COMPLIANT
const int g3 = 0; // COMPLIANT
extern const int g4 = 0; // COMPLIANT
static int g5; // COMPLIANT
namespace n1 { // named namespace as external linkage
int l1; // NON_COMPLIANT
void f1() {} // NON_COMPLIANT
} // namespace n1
namespace { // unnamed namespace has internal linkage
namespace n2 { // inherits internal linkage from unnamed namespace
int l1; // COMPLIANT
void f1() {} // COMPLIANT
} // namespace n2
} // namespace
int f() { // NON_COMPLIANT
return 1;
}
int f1(); // NON_COMPLIANT
static int f2() { // COMPLIANT
return 1;
}
int main(int, char **) { // COMPLIANT
}
namespace n {
void f5() { // COMPLIANT
int i = 0;
}
} // namespace n
const int c = 1; // COMPLIANT - internal linkage
const char *const str2 = "foo"; // COMPLIANT - internal linkage
constexpr int k = 1; // COMPLIANT - internal linkage