parent
557263acde
commit
2616046461
|
@ -1259,8 +1259,11 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
|
|||
fixVarId(varIds, tok, const_cast<Token *>(membertok), membervar);
|
||||
}
|
||||
} else if (tok->valueType() && tok->valueType()->type == ValueType::CONTAINER) {
|
||||
if (Token::Match(var->typeStartToken(), "std :: %type% < %type% *| *| >")) {
|
||||
const Type * type2 = var->typeStartToken()->tokAt(4)->type();
|
||||
if (Token::Match(var->typeStartToken(), "std :: %type% < %name%")) {
|
||||
const Token* type2tok = var->typeStartToken()->tokAt(4);
|
||||
while (type2tok && type2tok->isKeyword())
|
||||
type2tok = type2tok->next();
|
||||
const Type* type2 = type2tok ? type2tok->type() : nullptr;
|
||||
if (type2 && type2->classScope && type2->classScope->definedType) {
|
||||
const Variable *membervar = type2->classScope->getVariable(membertok->str());
|
||||
if (membervar) {
|
||||
|
|
|
@ -66,7 +66,7 @@ private:
|
|||
TEST_CASE(structmember16); // #10485
|
||||
TEST_CASE(structmember17); // #10591
|
||||
TEST_CASE(structmember18); // #10684
|
||||
TEST_CASE(structmember19); // #10826
|
||||
TEST_CASE(structmember19); // #10826, #10848
|
||||
|
||||
TEST_CASE(localvar1);
|
||||
TEST_CASE(localvar2);
|
||||
|
@ -1654,7 +1654,7 @@ private:
|
|||
"[test.cpp:5]: (style) struct member 'S::c' is never used.\n",
|
||||
errout.str());
|
||||
|
||||
checkStructMemberUsage("struct S {\n"
|
||||
checkStructMemberUsage("struct S {\n" // #10848
|
||||
" struct T {\n"
|
||||
" int i;\n"
|
||||
" } t[2];\n"
|
||||
|
@ -1701,6 +1701,15 @@ private:
|
|||
" return sp->a;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkStructMemberUsage("typedef struct { int i; } A;\n"
|
||||
"typedef struct { std::vector<A> v; } B;\n"
|
||||
"const A& f(const std::vector<const B*>& b, int idx) {\n"
|
||||
" const A& a = b[0]->v[idx];\n"
|
||||
" return a;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) struct member 'A::i' is never used.\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void functionVariableUsage_(const char* file, int line, const char code[], const char filename[] = "test.cpp") {
|
||||
|
|
Loading…
Reference in New Issue