| 8442 | // ------------------------------------------------------------------------ |
| 8443 | |
| 8444 | void Tokenizer::validateC() const |
| 8445 | { |
| 8446 | if (isCPP()) |
| 8447 | return; |
| 8448 | for (const Token *tok = tokens(); tok; tok = tok->next()) { |
| 8449 | // That might trigger false positives, but it's much faster to have this truncated pattern |
| 8450 | if (Token::Match(tok, "const_cast|dynamic_cast|reinterpret_cast|static_cast <")) |
| 8451 | syntaxErrorC(tok, "C++ cast <..."); |
| 8452 | // Template function.. |
| 8453 | if (Token::Match(tok, "%name% < %name% > (")) { |
| 8454 | const Token *tok2 = tok->tokAt(5); |
| 8455 | while (tok2 && !Token::Match(tok2, "[()]")) |
| 8456 | tok2 = tok2->next(); |
| 8457 | if (Token::simpleMatch(tok2, ") {")) |
| 8458 | syntaxErrorC(tok, tok->str() + '<' + tok->strAt(2) + ">() {}"); |
| 8459 | } |
| 8460 | if (tok->previous() && !Token::Match(tok->previous(), "[;{}]")) |
| 8461 | continue; |
| 8462 | if (Token::Match(tok, "using namespace %name% ;")) |
| 8463 | syntaxErrorC(tok, "using namespace " + tok->strAt(2)); |
| 8464 | if (Token::Match(tok, "template < class|typename %name% [,>]")) |
| 8465 | syntaxErrorC(tok, "template<..."); |
| 8466 | if (Token::Match(tok, "%name% :: %name%")) |
| 8467 | syntaxErrorC(tok, tok->str() + tok->strAt(1) + tok->strAt(2)); |
| 8468 | if (Token::Match(tok, "class|namespace %name% :|::|{")) |
| 8469 | syntaxErrorC(tok, tok->str() + tok->strAt(1) + tok->strAt(2)); |
| 8470 | } |
| 8471 | } |
| 8472 | |
| 8473 | void Tokenizer::validate() const |
| 8474 | { |