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
|
||||
{
|
||||
if (!isConstructor() || !functionScope || !functionScope->bodyStart)
|
||||
if (!isConstructor() || !arg)
|
||||
return nullptr;
|
||||
if (Token::Match(token, "%name% (") && Token::simpleMatch(token->linkAt(1), ") :"))
|
||||
return token->linkAt(1)->next();
|
||||
if (Token::simpleMatch(arg->link(), ") :"))
|
||||
return arg->link()->next();
|
||||
if (Token::simpleMatch(arg->link(), ") noexcept (") && arg->link()->linkAt(2)->strAt(1) == ":")
|
||||
return arg->link()->linkAt(2)->next();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -2499,6 +2499,26 @@ private:
|
|||
"}\n");
|
||||
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"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
|
|
Loading…
Reference in New Issue