Fixed setVarId on ternary operator in initialization list

This commit is contained in:
PKEuS 2015-02-22 11:57:46 +01:00
parent bae95b4560
commit f04070940e
2 changed files with 13 additions and 1 deletions

View File

@ -2491,7 +2491,7 @@ static void setVarIdClassDeclaration(Token * const startToken,
setVarIdStructMembers(&tok, structMembers, _varId);
}
}
} else if (indentlevel == 0 && tok->str() == ":")
} else if (indentlevel == 0 && tok->str() == ":" && !initListEndToken)
initListEndToken = findInitListEndToken(tok->previous());
}
}

View File

@ -1655,6 +1655,18 @@ private:
"3: int x@2 ;\n"
"4: } ;\n",
tokenize(code6));
// #6520
const char code7[] = "class A {\n"
" A(int x) : y(a?0:1), x(x) {}\n"
" int x, y;\n"
"};";
ASSERT_EQUALS("\n\n##file 0\n"
"1: class A {\n"
"2: A ( int x@1 ) : y@3 ( a ? 0 : 1 ) , x@2 ( x@1 ) { }\n"
"3: int x@2 ; int y@3 ;\n"
"4: } ;\n",
tokenize(code7));
}
void varid_operator() {