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

This commit is contained in:
chrchr-github 2023-03-12 11:13:58 +01:00 committed by GitHub
parent 7881b99547
commit 809430631f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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() {