Corrected noexcept constructor delegating handling (#948)

This commit is contained in:
Hinterwaeldlers 2017-09-02 22:54:23 +02:00 committed by Daniel Marjamäki
parent fc4f17dbc2
commit 8aa568f085
2 changed files with 24 additions and 3 deletions

View File

@ -1176,9 +1176,18 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass)
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) { for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
for (std::list<Function>::const_iterator func = it->functionList.begin(); func != it->functionList.end(); ++func) { for (std::list<Function>::const_iterator func = it->functionList.begin(); func != it->functionList.end(); ++func) {
// look for initializer list // look for initializer list
if (func->type == Function::eConstructor && func->functionScope && if (func->type == Function::eConstructor && func->functionScope && func->functionScope->functionOf && func->arg) {
func->functionScope->functionOf && func->arg && func->arg->link()->strAt(1) == ":") { const Token * tok = func->arg->link()->next();
const Token * tok = func->arg->link()->tokAt(2); if (tok->str() == "noexcept") {
if (!tok->linkAt(1) || !tok->linkAt(1)->next()) {
continue;
}
tok = tok->linkAt(1)->next();
}
if (tok->str() != ":") {
continue;
}
tok = tok->next();
while (tok && tok != func->functionScope->classStart) { while (tok && tok != func->functionScope->classStart) {
if (Token::Match(tok, "%name% {|(")) { if (Token::Match(tok, "%name% {|(")) {
if (tok->str() == func->tokenDef->str()) { if (tok->str() == func->tokenDef->str()) {

View File

@ -1074,6 +1074,18 @@ private:
"Foo::Foo() : Foo(0) {}\n" "Foo::Foo() : Foo(0) {}\n"
"Foo::Foo(int foo) : foo_(foo) {}\n"); "Foo::Foo(int foo) : foo_(foo) {}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Noexcept ctors
check("class A {\n"
"private:\n"
" int _a;\n"
"public:\n"
" A(const int a) noexcept : _a{a} {}\n"
" A() noexcept;\n"
"};\n"
"\n"
"A::A() noexcept: A(0) {}");
ASSERT_EQUALS("", errout.str());
} }