From 809430631ff07497f8692daf383dc3503574754d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sun, 12 Mar 2023 11:13:58 +0100 Subject: [PATCH] Partial fix for #11611 FP constStatement with typedef and unknown macro (#4881) --- lib/tokenize.cpp | 8 ++++---- test/testvarid.cpp | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c69beb680..bd68edc2e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3843,10 +3843,10 @@ void Tokenizer::setVarId() tok->varId(0); } - setPodTypes(); - setVarIdPass1(); + setPodTypes(); + setVarIdPass2(); } @@ -4144,7 +4144,7 @@ void Tokenizer::setVarIdPass1() } } - if (tok->isName() && !tok->isKeyword()) { + if (tok->isName() && !tok->isKeyword() && !tok->isStandardType()) { // don't set variable id after a struct|enum|union if (Token::Match(tok->previous(), "struct|enum|union") || (isCPP() && tok->strAt(-1) == "class")) continue; @@ -9588,7 +9588,7 @@ void Tokenizer::setPodTypes() if (!mSettings) return; for (Token *tok = list.front(); tok; tok = tok->next()) { - if (!tok->isName()) + if (!tok->isName() || tok->varId()) continue; // pod type diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 829d28564..1be6c2870 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -3015,6 +3015,9 @@ private: "2: char * text@1 ;\n" "3: void ( * f@2 ) ( int ( * arg ) ( char * ) ) ;\n" "4: }\n", tokenize(code2)); + + const char code3[] = "void f (void (*g) (int i, IN int n)) {}\n"; + ASSERT_EQUALS("1: void f ( void ( * g@1 ) ( int , IN int ) ) { }\n", tokenize(code3)); } void varidclass1() {