Merge pull request #245 from simartin/ticket_5478
Ticket #5478: Only functions and equal operators might return a temporary
This commit is contained in:
commit
4dee3da1bd
|
@ -292,6 +292,9 @@ bool CheckAutoVariables::returnTemporary(const Token *tok) const
|
|||
|
||||
const Function *function = tok->function();
|
||||
if (function) {
|
||||
// Ticket #5478: Only functions or operator equal might return a temporary
|
||||
if (function->type != Function::eOperatorEqual && function->type != Function::eFunction)
|
||||
return false;
|
||||
retref = function->tokenDef->strAt(-1) == "&";
|
||||
if (!retref) {
|
||||
const Token *start = function->retDef;
|
||||
|
|
|
@ -107,6 +107,8 @@ private:
|
|||
TEST_CASE(testglobalnamespace);
|
||||
|
||||
TEST_CASE(returnParameterAddress);
|
||||
|
||||
TEST_CASE(testconstructor); // ticket #5478 - crash
|
||||
}
|
||||
|
||||
|
||||
|
@ -814,6 +816,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void testconstructor() { // Ticket #5478 - crash while checking a constructor
|
||||
check("class const_tree_iterator {\n"
|
||||
" const_tree_iterator(bool (*_incream)(node_type*&)) {}\n"
|
||||
" const_tree_iterator& parent() {\n"
|
||||
" return const_tree_iterator(foo);\n"
|
||||
" }\n"
|
||||
"};");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestAutoVariables)
|
||||
|
|
Loading…
Reference in New Issue