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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
#pragma once
// Sample file for parse_enum unittests
#include <util/generic/fwd.h>
#include <util/system/compiler.h>
// Test template declarations
template<class T>
void Func(T&);
template<>
void Func(struct ENonDeclared&);
template<class TClass> class TFwdDecl;
// Test in-function class declarations
void InexistentFunction(struct TFwdStructDecl);
void InexistentFunction2(struct TFwdStructDecl, class TMegaClass);
static inline void Func() {
class TLocal {
int M;
public:
void F() {
// to shut up clang
Y_UNUSED(M);
}
};
{
// unnamed block
}
}
// Test forward declarations, pt 2
namespace NTestContainer {
struct TStruct;
}
// Enums
enum ESimple {
Http,
Https,
ItemCount
};
enum class ESimpleWithComma {
Http = 3,
Http2 = Http,
Https, // 4
ItemCount, // 5
};
enum ECustomAliases {
CAHttp = 3 /* "http" */,
CAHttps /* "https" */,
CAItemCount,
};
enum EMultipleAliases {
MAHttp = 9 /* "http://" "secondary" "old\nvalue" */,
MAHttps = 1 /* "https://" */,
MAItemCount,
};
namespace NEnumNamespace {
enum EInNamespace {
Http = 9 /* "http://" "secondary" "old\nvalue" */,
Https = 1 /* "https://" */,
ItemCount /* "real value" */,
};
};
struct TStruct {
int M;
};
namespace NEnumNamespace {
class TEnumClass: public TStruct {
public:
enum EInClass {
Http = 9 /* "http://" "secondary" "old\nvalue" */,
Https1 = NEnumNamespace::Https /* "https://" */,
// holy crap, this will work too:
Https3 = 1 /* "https://" */ + 2,
};
};
}
enum {
One,
Two,
Three,
};
struct {
int M;
} SomeStruct;
static inline void f() {
(void)(SomeStruct);
(void)(f);
}
// buggy case taken from library/cpp/html/face/parstypes.h
enum TEXT_WEIGHT {
WEIGHT_ZERO=-1,// NOINDEX_RELEV
WEIGHT_LOW, // LOW_RELEV
WEIGHT_NORMAL, // NORMAL_RELEV
WEIGHT_HIGH, // HIGH_RELEV (H1,H2,H3,ADDRESS,CAPTION)
WEIGHT_BEST // BEST_RELEV (TITLE)
};
// enum with duplicate keys
enum EDuplicateKeys {
Key0 = 0,
Key0Second = Key0,
Key1,
Key2 = 3 /* "k2" "k2.1" */,
Key3 = 3 /* "k3" */,
};
enum class EFwdEnum;
void FunctionUsingEFwdEnum(EFwdEnum);
enum class EFwdEnum {
One,
Two
};
// empty enum (bug found by sankear@)
enum EEmpty {
};
namespace NComposite::NInner {
enum EInCompositeNamespaceSimple {
one,
two = 2,
three,
};
}
namespace NOuterSimple {
namespace NComposite::NMiddle::NInner {
namespace NInnerSimple {
class TEnumClass {
public:
enum EVeryDeep {
Key0 = 0,
Key1 = 1,
};
};
}
}
}
constexpr int func(int value) {
return value;
}
#define MACRO(x, y) x
// enum with nonliteral values
enum ENonLiteralValues {
one = MACRO(1, 2),
two = 2,
three = func(3),
four,
five = MACRO(MACRO(1, 2), 2),
};
#undef MACRO
enum EDestructionPriorityTest {
first,
second
};
enum class NotifyingStatus
{
NEW = 0,
FAILED_WILL_RETRY = 1,
FAILED_NO_MORE_TRIALS = 2,
SENT = 3
};
/*
* Still unsupported features:
*
* a) Anonymous namespaces (it is parsed correctly, though)
* b) Enums inside template classes (impossible by design)
**/
|