File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1768,7 +1768,7 @@ void CheckOtherImpl::checkConstVariable()
17681768 continue ;
17691769 if (var->isConst ())
17701770 continue ;
1771- if (Token::Match (var->nameToken (), " %name% ) ( " )) // reference to function
1771+ if (Tokenizer::isFunctionPointer (var->nameToken ())) // reference to function
17721772 continue ;
17731773 const Scope* scope = var->scope ();
17741774 if (!scope)
Original file line number Diff line number Diff line change @@ -916,7 +916,8 @@ void SymbolDatabase::createSymbolDatabaseCopyAndMoveConstructors()
916916 continue ;
917917
918918 const Variable* firstArg = func->getArgumentVar (0 );
919- if (firstArg->type () == scope.definedType ) {
919+ // skip references to functions: Foo(Foo& (&f)())
920+ if (firstArg->type () == scope.definedType && !Token::Match (firstArg->typeEndToken (), " &|&& %name%| ) (" )) {
920921 if (firstArg->isRValueReference ())
921922 func->type = FunctionType::eMoveConstructor;
922923 else if (firstArg->isReference () && !firstArg->isPointer ())
Original file line number Diff line number Diff line change @@ -2475,6 +2475,26 @@ class TestSymbolDatabase : public TestFixture {
24752475 const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
24762476 ASSERT(db && ctor && ctor->type == FunctionType::eConstructor);
24772477 }
2478+ {
2479+ GET_SYMBOL_DB("class Foo { Foo(Foo& (&f)()); };\n");
2480+ const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
2481+ ASSERT(db && ctor && ctor->type == FunctionType::eConstructor);
2482+ }
2483+ {
2484+ GET_SYMBOL_DB("class Foo { Foo(Foo&& (&f)()); };\n");
2485+ const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
2486+ ASSERT(db && ctor && ctor->type == FunctionType::eConstructor);
2487+ }
2488+ {
2489+ GET_SYMBOL_DB("class Foo { Foo(Foo (&f)()); };\n");
2490+ const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
2491+ ASSERT(db && ctor && ctor->type == FunctionType::eConstructor);
2492+ }
2493+ {
2494+ GET_SYMBOL_DB("class Foo { Foo(Foo& (&)()); };\n");
2495+ const Function* ctor = tokenizer.tokens()->tokAt(3)->function();
2496+ ASSERT(db && ctor && ctor->type == FunctionType::eConstructor);
2497+ }
24782498 {
24792499 GET_SYMBOL_DB("void f() { extern void f(); }\n");
24802500 ASSERT(db && db->scopeList.size() == 2);
You can’t perform that action at this time.
0 commit comments