Detect syntax error when script is checked
This commit is contained in:
parent
af26697ceb
commit
5b89b179ec
|
@ -9563,6 +9563,10 @@ void Tokenizer::findGarbageCode() const
|
|||
}
|
||||
}
|
||||
|
||||
// array assignment
|
||||
else if (Token::Match(tok, "%assign% [") && Token::simpleMatch(tok->linkAt(1), "] ;"))
|
||||
syntaxError(tok, tok->str() + "[...];");
|
||||
|
||||
// UNKNOWN_MACRO(return)
|
||||
if (tok->isKeyword() && Token::Match(tok, "throw|return )") && Token::Match(tok->linkAt(1)->previous(), "%name% ("))
|
||||
unknownMacroError(tok->linkAt(1)->previous());
|
||||
|
|
|
@ -245,6 +245,7 @@ private:
|
|||
TEST_CASE(garbageCode212); // #8765
|
||||
TEST_CASE(garbageCode213); // #8758
|
||||
TEST_CASE(garbageCode214);
|
||||
TEST_CASE(garbageCode215); // daca@home script with extension .c
|
||||
|
||||
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
|
||||
|
||||
|
@ -1665,6 +1666,10 @@ private:
|
|||
checkCode("THIS FILE CONTAINS VARIOUS TEXT");
|
||||
}
|
||||
|
||||
void garbageCode215() { // daca@home script with extension .c
|
||||
ASSERT_THROW(checkCode("a = [1,2,3];"), InternalError);
|
||||
}
|
||||
|
||||
void syntaxErrorFirstToken() {
|
||||
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
|
||||
ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858
|
||||
|
|
Loading…
Reference in New Issue