Fixed #5871: Properly parse initialization list in setVarId() if constructor is declared as noexcept
This commit is contained in:
parent
9a679d1720
commit
274e1a838a
|
@ -2404,9 +2404,15 @@ static void setVarIdStructMembers(Token **tok1,
|
|||
|
||||
static const Token * findInitListEndToken(const Token *tok)
|
||||
{
|
||||
if (!Token::simpleMatch(tok, ") :"))
|
||||
if (!Token::Match(tok, ") noexcept|:") && !Token::simpleMatch(tok, "noexcept :"))
|
||||
return nullptr;
|
||||
|
||||
if (tok->strAt(1) != ":") {
|
||||
tok = tok->next();
|
||||
if (tok->strAt(1) == "(")
|
||||
tok = tok->linkAt(1);
|
||||
}
|
||||
|
||||
tok = tok->tokAt(2);
|
||||
|
||||
while (tok) {
|
||||
|
|
|
@ -1633,6 +1633,28 @@ private:
|
|||
"3: A ( int x@2 ) : x@1 ( x@2 ) { }\n"
|
||||
"4: } ;\n",
|
||||
tokenize(code4));
|
||||
|
||||
const char code5[] = "class A {\n"
|
||||
" A(int x) noexcept : x(x) {}\n"
|
||||
" int x;\n"
|
||||
"};";
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: class A {\n"
|
||||
"2: A ( int x@1 ) noexcept : x@2 ( x@1 ) { }\n"
|
||||
"3: int x@2 ;\n"
|
||||
"4: } ;\n",
|
||||
tokenize(code5));
|
||||
|
||||
const char code6[] = "class A {\n"
|
||||
" A(int x) noexcept(true) : x(x) {}\n"
|
||||
" int x;\n"
|
||||
"};";
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: class A {\n"
|
||||
"2: A ( int x@1 ) noexcept ( true ) : x@2 ( x@1 ) { }\n"
|
||||
"3: int x@2 ;\n"
|
||||
"4: } ;\n",
|
||||
tokenize(code6));
|
||||
}
|
||||
|
||||
void varid_operator() {
|
||||
|
|
Loading…
Reference in New Issue