@@ -103,14 +103,14 @@ static void skipEnumBody(T *&tok)
103103/* *
104104 * is tok the start brace { of a class, struct, union, or enum
105105 */
106- static const Token* isClassStructUnionEnumStart (const Token * tok)
106+ static bool isClassStructUnionEnumStart (const Token * tok)
107107{
108108 if (!Token::Match (tok->previous (), " class|struct|union|enum|%name%|>|>> {" ))
109- return nullptr ;
109+ return false ;
110110 const Token * tok2 = tok->previous ();
111111 while (tok2 && !Token::Match (tok2, " class|struct|union|enum|{|}|)|;|>|>>" ))
112112 tok2 = tok2->previous ();
113- return Token::Match (tok2, " class|struct|union|enum" ) ? tok2 : nullptr ;
113+ return Token::Match (tok2, " class|struct|union|enum" ) && ! Token::simpleMatch ( tok2-> tokAt (- 1 ), " -> " ) ;
114114}
115115
116116// ---------------------------------------------------------------------------
@@ -8783,16 +8783,12 @@ void Tokenizer::findGarbageCode() const
87838783 syntaxError (tok, " keyword '" + tok->str () + " ' is not allowed in global scope" );
87848784 }
87858785 for (const Token *tok = tokens (); tok; tok = tok->next ()) {
8786- if (tok->str () == " {" ) {
8787- if (const Token* start = isClassStructUnionEnumStart (tok)) {
8788- if (Token::simpleMatch (start->tokAt (-1 ), " ->" ))
8789- continue ;
8790- for (const Token* tok2 = tok->next (); tok2 != tok->link (); tok2 = tok2->next ()) {
8791- if (tok2->str () == " {" )
8792- tok2 = tok2->link ();
8793- else if (tok2->isKeyword () && nonGlobalKeywords.count (tok2->str ()) && !Token::Match (tok2->tokAt (-2 ), " operator %str%" ))
8794- syntaxError (tok2, " keyword '" + tok2->str () + " ' is not allowed in class/struct/union/enum scope" );
8795- }
8786+ if (tok->str () == " {" && isClassStructUnionEnumStart (tok)) {
8787+ for (const Token* tok2 = tok->next (); tok2 != tok->link (); tok2 = tok2->next ()) {
8788+ if (tok2->str () == " {" )
8789+ tok2 = tok2->link ();
8790+ else if (tok2->isKeyword () && nonGlobalKeywords.count (tok2->str ()) && !Token::Match (tok2->tokAt (-2 ), " operator %str%" ))
8791+ syntaxError (tok2, " keyword '" + tok2->str () + " ' is not allowed in class/struct/union/enum scope" );
87968792 }
87978793 }
87988794 }
0 commit comments