Skip to content

Commit

Permalink
C++: support enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Jun 11, 2018
1 parent 774060b commit a7502c9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions regression/cpp/enum_class1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ int main()
{
Color1 c;
c=Color1::red;

Color2 c2;
c2 = red;
}
2 changes: 1 addition & 1 deletion regression/cpp/enum_class1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp
-std=c++11
^EXIT=0$
Expand Down
6 changes: 6 additions & 0 deletions src/cpp/cpp_typecheck_enum_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ void cpp_typecheckt::typecheck_enum_type(typet &type)
cpp_scopes.put_into_scope(*new_symbol, dest_scope);

scope_identifier.id_class=cpp_idt::id_classt::CLASS;
scope_identifier.is_scope = true;

cpp_save_scopet save_scope(cpp_scopes);

if(new_symbol->type.get_bool(ID_C_class))
cpp_scopes.go_to(scope_identifier);

typecheck_enum_body(*new_symbol);
}
Expand Down
3 changes: 1 addition & 2 deletions src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4039,7 +4039,6 @@ bool Parser::rEnumSpec(typet &spec)
#endif

cpp_tokent tk;
// bool is_enum_class=false;

if(lex.get_token(tk)!=TOK_ENUM)
return false;
Expand All @@ -4053,7 +4052,7 @@ bool Parser::rEnumSpec(typet &spec)
if(lex.LookAhead(0)==TOK_CLASS)
{
lex.get_token(tk);
// is_enum_class=true;
spec.set(ID_C_class, true);
}

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

0 comments on commit a7502c9

Please sign in to comment.