Fixed #7346 (Tokenizer::setVarId: No varId for member in initialization list)
This commit is contained in:
parent
f64930b7f5
commit
2627aada07
|
@ -2969,10 +2969,12 @@ void Tokenizer::setVarId()
|
|||
tok2 = tok2->linkAt(2);
|
||||
|
||||
// constructor with initializer list
|
||||
if (Token::Match(tok2, ") : %name%")) {
|
||||
if (Token::Match(tok2, ") : ::| %name%")) {
|
||||
Token *tok3 = tok2;
|
||||
while (Token::Match(tok3, "[)}] [,:]")) {
|
||||
tok3 = tok3->tokAt(2);
|
||||
if (Token::Match(tok3, ":: %name%"))
|
||||
tok3 = tok3->next();
|
||||
while (Token::Match(tok3, "%name% :: %name%"))
|
||||
tok3 = tok3->tokAt(2);
|
||||
if (!Token::Match(tok3, "%name% (|{|<"))
|
||||
|
|
|
@ -166,6 +166,7 @@ private:
|
|||
TEST_CASE(varidclass16); // #4577
|
||||
TEST_CASE(varidclass17); // #6073
|
||||
TEST_CASE(varidclass18);
|
||||
TEST_CASE(varidclass19); // initializer list
|
||||
TEST_CASE(varid_classnameshaddowsvariablename); // #3990
|
||||
|
||||
TEST_CASE(varidnamespace1);
|
||||
|
@ -2845,6 +2846,21 @@ private:
|
|||
ASSERT_EQUALS(expected, tokenize(code));
|
||||
}
|
||||
|
||||
void varidclass19() {
|
||||
const char code[] = "class A : public ::B {\n"
|
||||
" int a;\n"
|
||||
" A();\n"
|
||||
"};\n"
|
||||
"A::A() : ::B(), a(0) {}";
|
||||
const char expected[] = "\n\n##file 0\n"
|
||||
"1: class A : public :: B {\n"
|
||||
"2: int a@1 ;\n"
|
||||
"3: A ( ) ;\n"
|
||||
"4: } ;\n"
|
||||
"5: A :: A ( ) : :: B ( ) , a@1 ( 0 ) { }\n";
|
||||
ASSERT_EQUALS(expected, tokenize(code));
|
||||
}
|
||||
|
||||
void varid_classnameshaddowsvariablename() {
|
||||
const char code[] = "class Data;\n"
|
||||
"void strange_declarated(const Data& Data);\n"
|
||||
|
|
Loading…
Reference in New Issue