Skip to content

Commit a7502c9

Browse files
committed
C++: support enum class
1 parent 774060b commit a7502c9

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

regression/cpp/enum_class1/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ int main()
1414
{
1515
Color1 c;
1616
c=Color1::red;
17+
18+
Color2 c2;
19+
c2 = red;
1720
}

regression/cpp/enum_class1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.cpp
33
-std=c++11
44
^EXIT=0$

src/cpp/cpp_typecheck_enum_type.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ void cpp_typecheckt::typecheck_enum_type(typet &type)
193193
cpp_scopes.put_into_scope(*new_symbol, dest_scope);
194194

195195
scope_identifier.id_class=cpp_idt::id_classt::CLASS;
196+
scope_identifier.is_scope = true;
197+
198+
cpp_save_scopet save_scope(cpp_scopes);
199+
200+
if(new_symbol->type.get_bool(ID_C_class))
201+
cpp_scopes.go_to(scope_identifier);
196202

197203
typecheck_enum_body(*new_symbol);
198204
}

src/cpp/parse.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4039,7 +4039,6 @@ bool Parser::rEnumSpec(typet &spec)
40394039
#endif
40404040

40414041
cpp_tokent tk;
4042-
// bool is_enum_class=false;
40434042

40444043
if(lex.get_token(tk)!=TOK_ENUM)
40454044
return false;
@@ -4053,7 +4052,7 @@ bool Parser::rEnumSpec(typet &spec)
40534052
if(lex.LookAhead(0)==TOK_CLASS)
40544053
{
40554054
lex.get_token(tk);
4056-
// is_enum_class=true;
4055+
spec.set(ID_C_class, true);
40574056
}
40584057

40594058
if(lex.LookAhead(0)!='{' &&

0 commit comments

Comments
 (0)