Ticket #6675: Fixed pattern detecting C++ 11 delegated constructors.

This commit is contained in:
Simon Martin 2015-05-10 11:27:47 +02:00
parent 96891dface
commit 25aff001e0
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) == ":") {
const Token * tok = func->arg->link()->tokAt(2);
while (tok && tok != func->functionScope->classStart) {
if (Token::Match(tok, "%name% {")) {
if (Token::Match(tok, "%name% {|(")) {
if (tok->str() == func->tokenDef->str()) {
const_cast<Token *>(tok)->function(func->functionScope->functionOf->findFunction(tok));
break;

View File

@ -1044,6 +1044,16 @@ private:
" A() { number = 42; }\n"
"};");
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());
}