Skip to content

C++: support enum class #2337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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