fix garbage code handling
This commit is contained in:
parent
2b31afe2ab
commit
fd19ab4ed1
|
@ -8087,7 +8087,7 @@ const Token * Tokenizer::findGarbageCode() const
|
|||
{
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "if|while|for|switch")) { // switch (EXPR) { ... }
|
||||
if (!Token::Match(tok->previous(), ";|{|}|(|)|,|else"))
|
||||
if (tok->previous() && !Token::Match(tok->previous(), ":|;|{|}|(|)|,|else|do"))
|
||||
return tok;
|
||||
if (!Token::Match(tok->next(), "( !!)"))
|
||||
return tok;
|
||||
|
|
|
@ -1229,7 +1229,7 @@ private:
|
|||
}
|
||||
|
||||
void garbageCode151() { // #4175
|
||||
checkCode(">{ x while (y) z int = }");
|
||||
ASSERT_THROW(checkCode(">{ x while (y) z int = }"), InternalError);
|
||||
checkCode("void f() {\n" // #4911 - bad simplification => don't crash
|
||||
" int a;\n"
|
||||
" do { a=do_something() } while (a);\n"
|
||||
|
@ -1317,9 +1317,9 @@ private:
|
|||
void garbageAST() {
|
||||
checkCode("--"); // don't crash
|
||||
|
||||
checkCode("N 1024 float a[N], b[N + 3], c[N]; void N; (void) i;\n"
|
||||
ASSERT_THROW(checkCode("N 1024 float a[N], b[N + 3], c[N]; void N; (void) i;\n"
|
||||
"int #define for (i = avx_test i < c[i]; i++)\n"
|
||||
"b[i + 3] = a[i] * {}"); // Don't hang (#5787)
|
||||
"b[i + 3] = a[i] * {}"), InternalError); // Don't hang (#5787)
|
||||
|
||||
checkCode("START_SECTION([EXTRA](bool isValid(const String &filename)))"); // Don't crash (#5991)
|
||||
}
|
||||
|
|
|
@ -1148,7 +1148,8 @@ private:
|
|||
|
||||
void ifAddBraces15() {
|
||||
// ticket #2616 - unknown macro before if
|
||||
ASSERT_EQUALS("{ A if ( x ) { y ( ) ; } }", tokenizeAndStringify("{A if(x)y();}", false));
|
||||
// TODO: Move to TestGarbage
|
||||
ASSERT_THROW(tokenizeAndStringify("{A if(x)y();}", false), InternalError);
|
||||
}
|
||||
|
||||
void ifAddBraces16() {
|
||||
|
|
Loading…
Reference in New Issue