Skip to content

Commit 8094306

Browse files
Partial fix for #11611 FP constStatement with typedef and unknown macro (#4881)
1 parent 7881b99 commit 8094306

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/tokenize.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,10 +3843,10 @@ void Tokenizer::setVarId()
38433843
tok->varId(0);
38443844
}
38453845

3846-
setPodTypes();
3847-
38483846
setVarIdPass1();
38493847

3848+
setPodTypes();
3849+
38503850
setVarIdPass2();
38513851
}
38523852

@@ -4144,7 +4144,7 @@ void Tokenizer::setVarIdPass1()
41444144
}
41454145
}
41464146

4147-
if (tok->isName() && !tok->isKeyword()) {
4147+
if (tok->isName() && !tok->isKeyword() && !tok->isStandardType()) {
41484148
// don't set variable id after a struct|enum|union
41494149
if (Token::Match(tok->previous(), "struct|enum|union") || (isCPP() && tok->strAt(-1) == "class"))
41504150
continue;
@@ -9588,7 +9588,7 @@ void Tokenizer::setPodTypes()
95889588
if (!mSettings)
95899589
return;
95909590
for (Token *tok = list.front(); tok; tok = tok->next()) {
9591-
if (!tok->isName())
9591+
if (!tok->isName() || tok->varId())
95929592
continue;
95939593

95949594
// pod type

test/testvarid.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,6 +3015,9 @@ class TestVarID : public TestFixture {
30153015
"2: char * text@1 ;\n"
30163016
"3: void ( * f@2 ) ( int ( * arg ) ( char * ) ) ;\n"
30173017
"4: }\n", tokenize(code2));
3018+
3019+
const char code3[] = "void f (void (*g) (int i, IN int n)) {}\n";
3020+
ASSERT_EQUALS("1: void f ( void ( * g@1 ) ( int , IN int ) ) { }\n", tokenize(code3));
30183021
}
30193022

30203023
void varidclass1() {

0 commit comments

Comments
 (0)