Fixed #7578 (varid not set for 'pointer to array' member variable in method)

This commit is contained in:
Daniel Marjamäki 2020-04-15 20:56:21 +02:00
parent 266c8d2c09
commit e4bea02cad
2 changed files with 16 additions and 1 deletions

View File

@ -3803,7 +3803,7 @@ void Tokenizer::setVarIdPass2()
if (tok2->strAt(-1) == ")" || tok2->strAt(-2) == ")")
setVarIdClassFunction(scopeName2 + classname, tok2, tok2->link(), thisClassVars, structMembers, &mVarId);
tok2 = tok2->link();
} else if (tok2->str() == "(" && tok2->link()->strAt(1) != "(") {
} else if (Token::Match(tok2, "( %name%|)") && !Token::Match(tok2->link(), "(|[")) {
tok2 = tok2->link();
// Skip initialization list

View File

@ -187,6 +187,7 @@ private:
TEST_CASE(varidclass17); // #6073
TEST_CASE(varidclass18);
TEST_CASE(varidclass19); // initializer list
TEST_CASE(varidclass20); // #7578: int (*p)[2]
TEST_CASE(varid_classnameshaddowsvariablename); // #3990
TEST_CASE(varidnamespace1);
@ -2989,6 +2990,20 @@ private:
ASSERT_EQUALS(expected, tokenize(code));
}
void varidclass20() { // #7578: int (*p)[2]
const char code[] = "struct S {\n"
" int (*p)[2];\n"
" S();\n"
"};\n"
"S::S() { p[0] = 0; }";
const char expected[] = "1: struct S {\n"
"2: int ( * p@1 ) [ 2 ] ;\n"
"3: S ( ) ;\n"
"4: } ;\n"
"5: S :: S ( ) { p@1 [ 0 ] = 0 ; }\n";
ASSERT_EQUALS(expected, tokenize(code));
}
void varid_classnameshaddowsvariablename() {
const char code[] = "class Data;\n"
"void strange_declarated(const Data& Data);\n"