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