forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
86 lines (64 loc) · 1.21 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
int id1;
namespace {
int id1; // NON_COMPLIANT
}
namespace ns1 {
int id1; // COMPLIANT
namespace ns2 {
int id1; // COMPLIANT
}
} // namespace ns1
class C1 {
int id1; // COMPLIANT
};
void f1() {
int id1; // NON_COMPLIANT
}
void f2(int id1) {} // NON_COMPLIANT
void f3() {
for (int id1; id1 < 1; id1++) { // NON_COMPLIANT
for (int id1; id1 < 1; id1++) {
} // NON_COMPLIANT
}
}
template <typename T> constexpr bool foo = false; // COMPLIANT
namespace {
template <typename T> bool foo = true; // COMPLIANT - omit variable templates
}
template <class T> constexpr T foo1 = T(1.1L);
template <class T, class R> T f(T r) {
T v = foo1<T> * r * r; // COMPLIANT
T v1 = foo1<R> * r * r; // COMPLIANT
}
void test_scope_order() {
{
{
int i; // COMPLIANT
}
int i; // COMPLIANT
}
for (int i = 0; i < 10; i++) { // COMPLIANT
}
try {
} catch (int i) { // COMPLIANT
}
int i; // COMPLIANT
{
{
int i; // NON_COMPLIANT
}
int i; // NON_COMPLIANT
}
for (int i = 0; i < 10; i++) { // NON_COMPLIANT
}
try {
} catch (int i) { // NON_COMPLIANT
}
}
int a;
namespace b {
int a() {} // NON_COMPLIANT
} // namespace b
namespace b1 {
typedef int a; // NON_COMPLIANT
}