From 502d7ea6dba3102e1a1ecadc22c8252deecf913b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:05:42 +0200 Subject: [PATCH] Fix #12120 FP constStatement with class in C code (#5594) --- lib/tokenize.cpp | 7 ------- test/testvarid.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7c44a856c6c..2fef09c0c62 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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()) { diff --git a/test/testvarid.cpp b/test/testvarid.cpp index e289f87efa3..ce43074dbbd 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -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); @@ -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"