Skip to content
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

C++ front-end: configure C++11+ syntax without ansi_c_parser object #8132

Merged
merged 1 commit into from
Jan 11, 2024
Merged
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
32 changes: 17 additions & 15 deletions src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,14 @@
class Parser // NOLINT(readability/identifiers)
{
public:
explicit Parser(cpp_parsert &_cpp_parser):
lex(_cpp_parser.token_buffer),
parser(_cpp_parser),
max_errors(10)
explicit Parser(cpp_parsert &_cpp_parser)
: lex(_cpp_parser.token_buffer),
parser(_cpp_parser),
max_errors(10),
cpp11(
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP11 ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14 ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP17)
{
root_scope.kind=new_scopet::kindt::NAMESPACE;
current_scope=&root_scope;
Expand Down Expand Up @@ -408,6 +412,7 @@
}

unsigned int max_errors;
const bool cpp11;
};

static bool is_identifier(int token)
Expand Down Expand Up @@ -1986,13 +1991,10 @@
{
int t=lex.LookAhead(0);

if(t==TOK_STATIC ||
t==TOK_EXTERN ||
(t == TOK_AUTO && !ansi_c_parser.cpp11) ||
t==TOK_REGISTER ||
t==TOK_MUTABLE ||
t==TOK_GCC_ASM ||
t==TOK_THREAD_LOCAL)
if(
t == TOK_STATIC || t == TOK_EXTERN || (t == TOK_AUTO && !cpp11) ||
t == TOK_REGISTER || t == TOK_MUTABLE || t == TOK_GCC_ASM ||
t == TOK_THREAD_LOCAL)
{
cpp_tokent tk;
lex.get_token(tk);
Expand Down Expand Up @@ -2730,7 +2732,7 @@

case TOK_DEFAULT: // C++0x
{
if(!ansi_c_parser.cpp11)
if(!cpp11)

Check warning on line 2735 in src/cpp/parse.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/parse.cpp#L2735

Added line #L2735 was not covered by tests
{
SyntaxError();
return false;
Expand All @@ -2743,7 +2745,7 @@

case TOK_DELETE: // C++0x
{
if(!ansi_c_parser.cpp11)
if(!cpp11)

Check warning on line 2748 in src/cpp/parse.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/parse.cpp#L2748

Added line #L2748 was not covered by tests
{
SyntaxError();
return false;
Expand Down Expand Up @@ -2907,7 +2909,7 @@

if(lex.LookAhead(0)==TOK_DEFAULT) // C++0x
{
if(!ansi_c_parser.cpp11)
if(!cpp11)

Check warning on line 2912 in src/cpp/parse.cpp

View check run for this annotation

Codecov / codecov/patch

src/cpp/parse.cpp#L2912

Added line #L2912 was not covered by tests
{
SyntaxError();
return false;
Expand All @@ -2919,7 +2921,7 @@
}
else if(lex.LookAhead(0)==TOK_DELETE) // C++0x
{
if(!ansi_c_parser.cpp11)
if(!cpp11)
{
SyntaxError();
return false;
Expand Down
Loading