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

Partial fix for #11611 FP constStatement with typedef and unknown macro #4881

Merged
merged 2 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
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
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 @@ -9586,7 +9586,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