@@ -8545,26 +8545,34 @@ void Tokenizer::findGarbageCode() const
8545
8545
syntaxError (tok);
8546
8546
}
8547
8547
8548
- if (tok->isControlFlowKeyword() && Token::Match(tok, "if|while|for|switch")) { // if|while|for|switch (EXPR) { ... }
8549
- if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|)")) {
8550
- if (Token::Match(tok->previous(), "[,(]")) {
8551
- const Token *prev = tok->previous();
8552
- while (prev && prev->str() != "(") {
8553
- if (prev->str() == ")")
8554
- prev = prev->link();
8555
- prev = prev->previous();
8548
+ if (tok->isControlFlowKeyword ()) {
8549
+ if (Token::Match (tok, " if|while|for|switch" )) { // if|while|for|switch (EXPR) { ... }
8550
+ if (tok->previous () && !Token::Match (tok->previous (), " %name%|:|;|{|}|)" )) {
8551
+ if (Token::Match (tok->previous (), " [,(]" )) {
8552
+ const Token *prev = tok->previous ();
8553
+ while (prev && prev->str () != " (" ) {
8554
+ if (prev->str () == " )" )
8555
+ prev = prev->link ();
8556
+ prev = prev->previous ();
8557
+ }
8558
+ if (prev && Token::Match (prev->previous (), " %name% (" ))
8559
+ unknownMacroError (prev->previous ());
8556
8560
}
8557
- if (prev && Token::Match(prev->previous( ), "%name% ( "))
8558
- unknownMacroError(prev->previous() );
8561
+ if (! Token::simpleMatch (tok-> tokAt (- 2 ), " operator \"\" if " ))
8562
+ syntaxError (tok );
8559
8563
}
8560
- if (!Token::simpleMatch (tok->tokAt(-2 ), "operator \"\" if "))
8564
+ if (!Token::Match (tok->next ( ), " ( !!) " ))
8561
8565
syntaxError (tok);
8566
+ if (tok->str () != " for" ) {
8567
+ if (isGarbageExpr (tok->next (), tok->linkAt (1 ), cpp && (mSettings .standards .cpp >=Standards::cppstd_t ::CPP17)))
8568
+ syntaxError (tok);
8569
+ }
8562
8570
}
8563
- if (! Token::Match (tok->next() , "( !!) "))
8564
- syntaxError( tok);
8565
- if (tok->str() != "for") {
8566
- if (isGarbageExpr (tok->next(), tok ->linkAt(1 ), cpp && (mSettings.standards.cpp>=Standards::cppstd_t::CPP17) ))
8567
- syntaxError(tok);
8571
+ if (Token::simpleMatch (tok, " do { " )) {
8572
+ if (! Token::simpleMatch ( tok-> linkAt ( 1 ), " } while ( " ))
8573
+ syntaxError (tok->linkAt ( 1 ));
8574
+ if (! Token::simpleMatch (tok->linkAt ( 1 ) ->linkAt (2 ), " ) ; " ))
8575
+ syntaxError (tok-> linkAt ( 1 )-> linkAt ( 2 ) );
8568
8576
}
8569
8577
}
8570
8578
0 commit comments