@@ -3543,7 +3543,7 @@ void VariableMap::addVariable(const std::string& varname, bool globalNamespace)
35433543}
35443544
35453545
3546- static bool setVarIdParseDeclaration (const Token **tok, const VariableMap& variableMap, bool executableScope, bool cpp, bool c)
3546+ static bool setVarIdParseDeclaration (const Token **tok, const VariableMap& variableMap, bool executableScope, bool cpp, bool c, bool header )
35473547{
35483548 const Token *tok2 = *tok;
35493549 if (!tok2->isName ())
@@ -3563,7 +3563,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const VariableMap& varia
35633563 tok2 = tok2->linkAt (1 )->next ();
35643564 continue ;
35653565 }
3566- if (Token::Match (tok2, " struct|union|enum" ) || (!c && Token::Match (tok2, " class|typename" ))) {
3566+ if (Token::Match (tok2, " struct|union|enum" ) || ((!c || header) && Token::Match (tok2, " class|typename" ))) {
35673567 hasstruct = true ;
35683568 typeCount = 0 ;
35693569 singleNameCount = 0 ;
@@ -3579,8 +3579,8 @@ static bool setVarIdParseDeclaration(const Token **tok, const VariableMap& varia
35793579 ++typeCount;
35803580 ++singleNameCount;
35813581 }
3582- } else if (!c && ((TemplateSimplifier::templateParameters (tok2) > 0 ) ||
3583- Token::simpleMatch (tok2, " < >" ) /* Ticket #4764 */ )) {
3582+ } else if ((!c || header) && ((TemplateSimplifier::templateParameters (tok2) > 0 ) ||
3583+ Token::simpleMatch (tok2, " < >" ) /* Ticket #4764 */ )) {
35843584 const Token *start = *tok;
35853585 if (Token::Match (start->previous (), " %or%|%oror%|&&|&|^|+|-|*|/" ))
35863586 return false ;
@@ -4053,7 +4053,7 @@ void Tokenizer::setVarIdPass1()
40534053 }
40544054
40554055 try { /* Ticket #8151 */
4056- decl = setVarIdParseDeclaration (&tok2, variableMap, scopeStack.top ().isExecutable , isCPP (), isC ());
4056+ decl = setVarIdParseDeclaration (&tok2, variableMap, scopeStack.top ().isExecutable , isCPP (), isC (), isHeader () );
40574057 } catch (const Token * errTok) {
40584058 syntaxError (errTok);
40594059 }
0 commit comments