Fixed false positive: Parameter can be declared with const in constructors did handle noexcept
Merged from LCppC.
This commit is contained in:
parent
a8657ac599
commit
aa2f143ea6
|
@ -2678,10 +2678,12 @@ std::vector<const Token*> Function::findReturns(const Function* f)
|
||||||
|
|
||||||
const Token * Function::constructorMemberInitialization() const
|
const Token * Function::constructorMemberInitialization() const
|
||||||
{
|
{
|
||||||
if (!isConstructor() || !functionScope || !functionScope->bodyStart)
|
if (!isConstructor() || !arg)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (Token::Match(token, "%name% (") && Token::simpleMatch(token->linkAt(1), ") :"))
|
if (Token::simpleMatch(arg->link(), ") :"))
|
||||||
return token->linkAt(1)->next();
|
return arg->link()->next();
|
||||||
|
if (Token::simpleMatch(arg->link(), ") noexcept (") && arg->link()->linkAt(2)->strAt(1) == ":")
|
||||||
|
return arg->link()->linkAt(2)->next();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2499,6 +2499,26 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("class C\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" explicit C(int&);\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"class D\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" explicit D(int&) noexcept;\n"
|
||||||
|
"\n"
|
||||||
|
"private:\n"
|
||||||
|
" C c;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"D::D(int& i) noexcept\n"
|
||||||
|
" : c(i)\n"
|
||||||
|
"{}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("class C\n"
|
check("class C\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"public:\n"
|
"public:\n"
|
||||||
|
|
Loading…
Reference in New Issue