Skip to content

Commit

Permalink
Partial fix for #11611 FP constStatement with typedef and unknown mac…
Browse files Browse the repository at this point in the history
…ro (#4881)
  • Loading branch information
chrchr-github authored Mar 12, 2023
1 parent 7881b99 commit 8094306
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3843,10 +3843,10 @@ void Tokenizer::setVarId()
tok->varId(0);
}

setPodTypes();

setVarIdPass1();

setPodTypes();

setVarIdPass2();
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3015,6 +3015,9 @@ class TestVarID : public TestFixture {
"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() {
Expand Down

0 comments on commit 8094306

Please sign in to comment.