Merge pull request #593 from simartin/ticket_6675

Ticket #6675: Fixed pattern detecting C++ 11 delegated constructors.
This commit is contained in:
PKEuS 2015-05-10 22:50:49 +02:00
commit 8bbf8f1b50
2 changed files with 11 additions and 1 deletions

View File

@ -1198,7 +1198,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
func->functionScope->functionOf && func->arg && func->arg->link()->strAt(1) == ":") { func->functionScope->functionOf && func->arg && func->arg->link()->strAt(1) == ":") {
const Token * tok = func->arg->link()->tokAt(2); const Token * tok = func->arg->link()->tokAt(2);
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()) {
const_cast<Token *>(tok)->function(func->functionScope->functionOf->findFunction(tok)); const_cast<Token *>(tok)->function(func->functionScope->functionOf->findFunction(tok));
break; break;

View File

@ -1044,6 +1044,16 @@ private:
" A() { number = 42; }\n" " A() { number = 42; }\n"
"};"); "};");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Ticket #6675
check("struct Foo {\n"
" Foo();\n"
" Foo(int foo);\n"
" int foo_;\n"
"};\n"
"Foo::Foo() : Foo(0) {}\n"
"Foo::Foo(int foo) : foo_(foo) {}\n");
ASSERT_EQUALS("", errout.str());
} }