Fixed setVarId() for template in initializer list (#7122)
This commit is contained in:
parent
feae241fc0
commit
cc9a1f4375
|
@ -2962,15 +2962,20 @@ void Tokenizer::setVarId()
|
||||||
}
|
}
|
||||||
|
|
||||||
// constructor with initializer list
|
// constructor with initializer list
|
||||||
if (Token::Match(tok2, ") : %name% (|{")) {
|
if (Token::Match(tok2, ") : %name% (|{|<")) {
|
||||||
Token *tok3 = tok2;
|
Token *tok3 = tok2;
|
||||||
do {
|
do {
|
||||||
Token *vartok = tok3->tokAt(2);
|
Token *vartok = tok3->tokAt(2);
|
||||||
std::map<std::string, unsigned int>::const_iterator varpos = thisClassVars.find(vartok->str());
|
std::map<std::string, unsigned int>::const_iterator varpos = thisClassVars.find(vartok->str());
|
||||||
if (varpos != thisClassVars.end())
|
if (varpos != thisClassVars.end())
|
||||||
vartok->varId(varpos->second);
|
vartok->varId(varpos->second);
|
||||||
tok3 = vartok->linkAt(1);
|
if (vartok->strAt(1) == "<") {
|
||||||
} while (Token::Match(tok3, ")|} [:,] %name% (|{"));
|
tok3 = vartok->next()->findClosingBracket();
|
||||||
|
if (tok3 && tok3->next()->link())
|
||||||
|
tok3 = tok3->next()->link();
|
||||||
|
} else
|
||||||
|
tok3 = vartok->linkAt(1);
|
||||||
|
} while (Token::Match(tok3, ")|} [:,] %name% (|{|<"));
|
||||||
if (Token::Match(tok3, ")|} {")) {
|
if (Token::Match(tok3, ")|} {")) {
|
||||||
setVarIdClassFunction(classname, tok2, tok3->next()->link(), thisClassVars, structMembers, &_varId);
|
setVarIdClassFunction(classname, tok2, tok3->next()->link(), thisClassVars, structMembers, &_varId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1859,6 +1859,23 @@ private:
|
||||||
"3: A ( int x@2 ) : x@1 ( x@2 ) { }\n"
|
"3: A ( int x@2 ) : x@1 ( x@2 ) { }\n"
|
||||||
"4: } ;\n",
|
"4: } ;\n",
|
||||||
tokenize(code4));
|
tokenize(code4));
|
||||||
|
|
||||||
|
const char code5[] = "class BCLass : public Ticket<void> {\n"
|
||||||
|
" BCLass();\n"
|
||||||
|
" PClass* member;\n"
|
||||||
|
"};\n"
|
||||||
|
"BCLass::BCLass() : Ticket<void>() {\n"
|
||||||
|
" member = 0;\n"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS("\n\n##file 0\n"
|
||||||
|
"1: class BCLass : public Ticket < void > {\n"
|
||||||
|
"2: BCLass ( ) ;\n"
|
||||||
|
"3: PClass * member@1 ;\n"
|
||||||
|
"4: } ;\n"
|
||||||
|
"5: BCLass :: BCLass ( ) : Ticket < void > ( ) {\n"
|
||||||
|
"6: member@1 = 0 ;\n"
|
||||||
|
"7: }\n",
|
||||||
|
tokenize(code5));
|
||||||
}
|
}
|
||||||
|
|
||||||
void varid_operator() {
|
void varid_operator() {
|
||||||
|
|
Loading…
Reference in New Issue