@@ -9004,19 +9004,6 @@ void Tokenizer::findGarbageCode() const
90049004 syntaxError (tok);
90059005 }
90069006
9007- // Invalid integer literal as argument of a possible macro
9008- if (tok->isNumber () && MathLib::isInt (tok->str ()) && isTooLargeInt (tok)) {
9009- const Token *prev = tok->previous ();
9010- while (prev && !Token::Match (prev, " (|;|{|}" )) {
9011- if (Token::Match (prev, " )|]" ))
9012- prev = prev->link ();
9013- prev = prev->previous ();
9014- }
9015- if (prev && prev->str () == " (" && Token::Match (prev->previous (), " %name% (" ) && !prev->previous ()->isKeyword ())
9016- unknownMacroError (prev->previous ());
9017- syntaxError (tok, " integer literal too large" );
9018- }
9019-
90209007 if (tok->isControlFlowKeyword ()) {
90219008 if (Token::Match (tok, " if|while|for|switch" )) { // if|while|for|switch (EXPR) { ... }
90229009 if (tok->previous () && !Token::Match (tok->previous (), " %name%|:|;|{|}|)" )) {
@@ -9466,6 +9453,21 @@ void Tokenizer::findGarbageCode() const
94669453 if (Token::Match (tok, " [;{}] [ %name% %name% ] ;" ))
94679454 syntaxError (tok->next ());
94689455 }
9456+
9457+ // Integer literal too large: argument of a possible macro, or invalid code.
9458+ for (const Token *tok = tokens (); tok; tok = tok->next ()) {
9459+ if (!tok->isNumber () || !MathLib::isInt (tok->str ()) || !isTooLargeInt (tok))
9460+ continue ;
9461+ const Token *prev = tok->previous ();
9462+ while (prev && prev->str () != " (" ) {
9463+ if (Token::Match (prev, " )|]|}" ))
9464+ prev = prev->link ();
9465+ prev = prev->previous ();
9466+ }
9467+ if (prev && Token::Match (prev->previous (), " %name% (" ) && !prev->previous ()->isKeyword ())
9468+ unknownMacroError (prev->previous ());
9469+ syntaxError (tok, " integer literal too large" );
9470+ }
94699471}
94709472
94719473
0 commit comments