@@ -3432,14 +3432,15 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Library&
34323432 if (!ftok)
34333433 return ExprUsage::None;
34343434 const Function* func = ftok->function ();
3435+ const Variable* var = ftok->variable ();
34353436 // variable init/constructor call?
3436- if (!func && ftok-> variable () && ftok == ftok-> variable () ->nameToken ()) {
3437- // STL types or containers don't initialize external variables
3438- if (indirect == 0 && (ftok-> variable ()-> isStlType () || (ftok-> variable () ->valueType () && ftok-> variable ()->valueType ()-> container )))
3437+ if (!func && var && ftok == var ->nameToken ()) {
3438+ // STL types/ containers/primitive types don't initialize external variables
3439+ if (indirect == 0 && (var-> isStlType () || (var-> valueType () && (var ->valueType ()-> container || (var-> valueType ()->isPrimitive () && !var-> isReference ())) )))
34393440 return ExprUsage::Used;
34403441 // TODO: resolve multiple constructors
3441- if (ftok-> variable ()-> type () && ftok-> variable () ->type ()->classScope ) {
3442- const int nCtor = ftok-> variable () ->type ()->classScope ->numConstructors ;
3442+ if (var-> type () && var ->type ()->classScope ) {
3443+ const int nCtor = var ->type ()->classScope ->numConstructors ;
34433444 if (nCtor == 0 ) {
34443445 if (indirect > 0 ) {
34453446 const std::vector<const Variable*> argvar = getArgumentVars (ftok->astParent (), argnr);
@@ -3449,7 +3450,7 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Library&
34493450 return ExprUsage::Used;
34503451 }
34513452 if (nCtor == 1 ) {
3452- const Scope* scope = ftok-> variable () ->type ()->classScope ;
3453+ const Scope* scope = var ->type ()->classScope ;
34533454 auto it = std::find_if (scope->functionList .begin (), scope->functionList .end (), [](const Function& f) {
34543455 return f.isConstructor ();
34553456 });
0 commit comments