VarId: Set varid for template parameters (#7046)
This commit is contained in:
parent
6d0c2f7253
commit
c7f5ca74bd
|
@ -2788,6 +2788,20 @@ void Tokenizer::setVarId()
|
||||||
|
|
||||||
if (decl) {
|
if (decl) {
|
||||||
variableId[prev2->str()] = ++_varId;
|
variableId[prev2->str()] = ++_varId;
|
||||||
|
|
||||||
|
// set varid for template parameters..
|
||||||
|
tok = tok->next();
|
||||||
|
while (Token::Match(tok, "%name%|::"))
|
||||||
|
tok = tok->next();
|
||||||
|
if (tok && tok->str() == "<") {
|
||||||
|
const Token *end = tok->findClosingBracket();
|
||||||
|
while (tok != end) {
|
||||||
|
if (tok->isName() && variableId.find(tok->str()) != variableId.end())
|
||||||
|
tok->varId(variableId[tok->str()]);
|
||||||
|
tok = tok->next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tok = tok2->previous();
|
tok = tok2->previous();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ private:
|
||||||
TEST_CASE(varid_templatePtr); // #4319
|
TEST_CASE(varid_templatePtr); // #4319
|
||||||
TEST_CASE(varid_templateNamespaceFuncPtr); // #4172
|
TEST_CASE(varid_templateNamespaceFuncPtr); // #4172
|
||||||
TEST_CASE(varid_templateArray);
|
TEST_CASE(varid_templateArray);
|
||||||
|
TEST_CASE(varid_templateParameter); // #7046 set varid for "X": std::array<int,X> Y;
|
||||||
TEST_CASE(varid_cppcast); // #6190
|
TEST_CASE(varid_cppcast); // #6190
|
||||||
TEST_CASE(varid_variadicFunc);
|
TEST_CASE(varid_variadicFunc);
|
||||||
TEST_CASE(varid_typename); // #4644
|
TEST_CASE(varid_typename); // #4644
|
||||||
|
@ -2135,6 +2136,16 @@ private:
|
||||||
tokenize("VertexArrayIterator<float[2]> attrPos = m_AttributePos.GetIterator<float[2]>();"));
|
tokenize("VertexArrayIterator<float[2]> attrPos = m_AttributePos.GetIterator<float[2]>();"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void varid_templateParameter() { // #7046 set varid for "X": std::array<int,X> Y;
|
||||||
|
const char code[] = "const int X = 0;\n"
|
||||||
|
"std::array<int,X> Y;\n";
|
||||||
|
|
||||||
|
ASSERT_EQUALS("\n\n##file 0\n"
|
||||||
|
"1: const int X@1 = 0 ;\n"
|
||||||
|
"2: std :: array < int , X@1 > Y@2 ;\n",
|
||||||
|
tokenize(code));
|
||||||
|
}
|
||||||
|
|
||||||
void varid_cppcast() {
|
void varid_cppcast() {
|
||||||
ASSERT_EQUALS("\n\n##file 0\n1: const_cast < int * > ( code ) [ 0 ] = 0 ;\n",
|
ASSERT_EQUALS("\n\n##file 0\n1: const_cast < int * > ( code ) [ 0 ] = 0 ;\n",
|
||||||
tokenize("const_cast<int *>(code)[0] = 0;"));
|
tokenize("const_cast<int *>(code)[0] = 0;"));
|
||||||
|
|
Loading…
Reference in New Issue