Fix bug in lifetime constructors (#1816)
This commit is contained in:
parent
7260bdd6d8
commit
71bd7f68d4
|
@ -3189,6 +3189,7 @@ static void valueFlowLifetimeConstructor(Token *tok, TokenList *tokenlist, Error
|
||||||
} else {
|
} else {
|
||||||
ls.byVal(tok, tokenlist, errorLogger, settings);
|
ls.byVal(tok, tokenlist, errorLogger, settings);
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Token::simpleMatch(tok, "{") && (astIsContainer(tok->astParent()) || astIsPointer(tok->astParent()))) {
|
} else if (Token::simpleMatch(tok, "{") && (astIsContainer(tok->astParent()) || astIsPointer(tok->astParent()))) {
|
||||||
|
|
|
@ -1966,6 +1966,13 @@ private:
|
||||||
" return A{x, x};\n"
|
" return A{x, x};\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void danglingLifetimeInitList() {
|
||||||
|
|
Loading…
Reference in New Issue