@@ -4079,7 +4079,7 @@ void VariableMap::addVariable(const std::string& varname, bool globalNamespace)
40794079 it->second = ++mVarId ;
40804080}
40814081
4082- static bool setVarIdParseDeclaration (Token** tok, const VariableMap& variableMap, bool executableScope, bool cpp, bool c)
4082+ static bool setVarIdParseDeclaration (Token** tok, const VariableMap& variableMap, bool executableScope, bool cpp, bool c, bool header )
40834083{
40844084 const Token* const tok1 = *tok;
40854085 Token* tok2 = *tok;
@@ -4104,7 +4104,7 @@ static bool setVarIdParseDeclaration(Token** tok, const VariableMap& variableMap
41044104 tok2 = tok2->linkAt (1 )->next ();
41054105 continue ;
41064106 }
4107- if (Token::Match (tok2, " struct|union|enum" ) || (!c && Token::Match (tok2, " class|typename" ))) {
4107+ if (Token::Match (tok2, " struct|union|enum" ) || ((!c || header) && Token::Match (tok2, " class|typename" ))) {
41084108 hasstruct = true ;
41094109 typeCount = 0 ;
41104110 singleNameCount = 0 ;
@@ -4120,8 +4120,8 @@ static bool setVarIdParseDeclaration(Token** tok, const VariableMap& variableMap
41204120 ++typeCount;
41214121 ++singleNameCount;
41224122 }
4123- } else if (!c && ((TemplateSimplifier::templateParameters (tok2) > 0 ) ||
4124- Token::simpleMatch (tok2, " < >" ) /* Ticket #4764 */ )) {
4123+ } else if ((!c || header) && ((TemplateSimplifier::templateParameters (tok2) > 0 ) ||
4124+ Token::simpleMatch (tok2, " < >" ) /* Ticket #4764 */ )) {
41254125 const Token *start = *tok;
41264126 if (Token::Match (start->previous (), " %or%|%oror%|&&|&|^|+|-|*|/" ))
41274127 return false ;
@@ -4601,7 +4601,7 @@ void Tokenizer::setVarIdPass1()
46014601 }
46024602
46034603 try { /* Ticket #8151 */
4604- decl = setVarIdParseDeclaration (&tok2, variableMap, scopeStack.top ().isExecutable , isCPP (), isC ());
4604+ decl = setVarIdParseDeclaration (&tok2, variableMap, scopeStack.top ().isExecutable , isCPP (), isC (), isHeader () );
46054605 } catch (const Token * errTok) {
46064606 syntaxError (errTok);
46074607 }
0 commit comments