From 25aff001e0ea04eb7782e067897981bce549e9af Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sun, 10 May 2015 11:27:47 +0200 Subject: [PATCH] Ticket #6675: Fixed pattern detecting C++ 11 delegated constructors. --- lib/symboldatabase.cpp | 2 +- test/testconstructors.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 03e6360c2..37712f4c4 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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(tok)->function(func->functionScope->functionOf->findFunction(tok)); break; diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 2ac9e9a3d..a078c6cd7 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -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()); }