This commit is contained in:
parent
d08709d10f
commit
8878e6dd0d
|
@ -3082,6 +3082,10 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
|||
// skip over stuff to get to type
|
||||
while (Token::Match(typeTok, "const|enum|struct|::"))
|
||||
typeTok = typeTok->next();
|
||||
if (Token::Match(typeTok, ",|)")) { // #8333
|
||||
symbolDatabase->_tokenizer->syntaxError(typeTok);
|
||||
return;
|
||||
}
|
||||
// skip over qualification
|
||||
while (Token::Match(typeTok, "%type% ::"))
|
||||
typeTok = typeTok->tokAt(2);
|
||||
|
|
|
@ -221,6 +221,7 @@ private:
|
|||
TEST_CASE(garbageCode188);
|
||||
TEST_CASE(garbageCode189); // #8317
|
||||
TEST_CASE(garbageCode190); // #8307
|
||||
TEST_CASE(garbageCode191); // #8333
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
TEST_CASE(garbageAST);
|
||||
|
@ -1203,7 +1204,7 @@ private:
|
|||
"{\n"
|
||||
" (foo(s, , 2, , , 5, , 7)) abort()\n"
|
||||
"}\n";
|
||||
checkCode(code);
|
||||
ASSERT_THROW(checkCode(code), InternalError);
|
||||
|
||||
// #6106
|
||||
code = " f { int i ; b2 , [ ] ( for ( i = 0 ; ; ) ) }";
|
||||
|
@ -1451,6 +1452,15 @@ private:
|
|||
"}");
|
||||
}
|
||||
|
||||
void garbageCode191() { // #8333
|
||||
ASSERT_THROW(checkCode("struct A { int f(const); };"), InternalError);
|
||||
ASSERT_THROW(checkCode("struct A { int f(int, const, char); };"), InternalError);
|
||||
ASSERT_THROW(checkCode("struct A { int f(struct); };"), InternalError);
|
||||
|
||||
// The following code is valid and should not trigger any error
|
||||
checkCode("struct A { int f ( char ) ; } ;");
|
||||
}
|
||||
|
||||
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