Fix bug in lifetime constructors (#1816)

This commit is contained in:
Paul Fultz II 2019-05-01 00:52:52 -05:00 committed by Daniel Marjamäki
parent 7260bdd6d8
commit 71bd7f68d4
2 changed files with 8 additions and 0 deletions

View File

@ -3189,6 +3189,7 @@ static void valueFlowLifetimeConstructor(Token *tok, TokenList *tokenlist, Error
} else {
ls.byVal(tok, tokenlist, errorLogger, settings);
}
i++;
}
}
} else if (Token::simpleMatch(tok, "{") && (astIsContainer(tok->astParent()) || astIsPointer(tok->astParent()))) {

View File

@ -1966,6 +1966,13 @@ private:
" return A{x, x};\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("struct A { int i; const int& j; };\n"
"A f(int& x) {\n"
" int y = 0;\n"
" return A{y, x};\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void danglingLifetimeInitList() {