Fix regression: wrong member variable (#3987)
This commit is contained in:
parent
d2a0b0f78e
commit
38bc0ad4c3
|
@ -1240,7 +1240,7 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
|
||||||
membertok = membertok->astOperand2();
|
membertok = membertok->astOperand2();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (membertok) {
|
if (membertok && membertok != tok) {
|
||||||
const Variable *var = tok->variable();
|
const Variable *var = tok->variable();
|
||||||
if (var->typeScope()) {
|
if (var->typeScope()) {
|
||||||
const Variable *membervar = var->typeScope()->getVariable(membertok->str());
|
const Variable *membervar = var->typeScope()->getVariable(membertok->str());
|
||||||
|
|
|
@ -185,6 +185,7 @@ private:
|
||||||
TEST_CASE(arrayMemberVar1);
|
TEST_CASE(arrayMemberVar1);
|
||||||
TEST_CASE(arrayMemberVar2);
|
TEST_CASE(arrayMemberVar2);
|
||||||
TEST_CASE(arrayMemberVar3);
|
TEST_CASE(arrayMemberVar3);
|
||||||
|
TEST_CASE(arrayMemberVar4);
|
||||||
TEST_CASE(staticMemberVar);
|
TEST_CASE(staticMemberVar);
|
||||||
TEST_CASE(getVariableFromVarIdBoundsCheck);
|
TEST_CASE(getVariableFromVarIdBoundsCheck);
|
||||||
|
|
||||||
|
@ -1433,6 +1434,19 @@ private:
|
||||||
ASSERT(tok && tok->varId() == 3U); // It's possible to set a varId
|
ASSERT(tok && tok->varId() == 3U); // It's possible to set a varId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void arrayMemberVar4() {
|
||||||
|
GET_SYMBOL_DB("struct S { unsigned char* s; };\n"
|
||||||
|
"struct T { S s[38]; };\n"
|
||||||
|
"void f(T* t) {\n"
|
||||||
|
" t->s;\n"
|
||||||
|
"}\n");
|
||||||
|
const Token *tok = Token::findsimplematch(tokenizer.tokens(), ". s");
|
||||||
|
tok = tok ? tok->next() : nullptr;
|
||||||
|
ASSERT(db != nullptr);
|
||||||
|
ASSERT(tok && tok->variable() && Token::simpleMatch(tok->variable()->typeStartToken(), "S s [ 38 ] ;"));
|
||||||
|
ASSERT(tok && tok->varId() == 4U);
|
||||||
|
}
|
||||||
|
|
||||||
void staticMemberVar() {
|
void staticMemberVar() {
|
||||||
GET_SYMBOL_DB("class Foo {\n"
|
GET_SYMBOL_DB("class Foo {\n"
|
||||||
" static const double d;\n"
|
" static const double d;\n"
|
||||||
|
|
Loading…
Reference in New Issue