Skip to content

Commit

Permalink
Fix #12120 FP constStatement with class in C code (danmar#5594)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Oct 25, 2023
1 parent 122e142 commit 502d7ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5616,13 +5616,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// If typedef handling is refactored and moved to symboldatabase someday we can remove this
prepareTernaryOpForAST();

for (Token* tok = list.front(); tok;) {
if (Token::Match(tok, "union|struct|class union|struct|class"))
tok->deleteNext();
else
tok = tok->next();
}

// class x y {
if (isCPP() && mSettings->severity.isEnabled(Severity::information)) {
for (const Token *tok = list.front(); tok; tok = tok->next()) {
Expand Down
7 changes: 7 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class TestVarID : public TestFixture {
TEST_CASE(varid_for_2);
TEST_CASE(varid_cpp_keywords_in_c_code);
TEST_CASE(varid_cpp_keywords_in_c_code2); // #5373: varid=0 for argument called "delete"
TEST_CASE(varid_cpp_keywords_in_c_code3);
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
Expand Down Expand Up @@ -1298,6 +1299,12 @@ class TestVarID : public TestFixture {
tokenize(code, "test.c");
}

void varid_cpp_keywords_in_c_code3() { // #12120
const char code[] = "const struct class *p;";
const char expected[] = "1: const struct class * p@1 ;\n";
ASSERT_EQUALS(expected, tokenize(code, "test.c"));
}

void varidFunctionCall1() {
const char code[] ="void f() {\n"
" int x;\n"
Expand Down

0 comments on commit 502d7ea

Please sign in to comment.