Throw more syntaxErrors from SymbolDatabase, fixing #5663

This commit is contained in:
PKEuS 2014-04-10 20:11:03 +02:00
parent 25b1f2f541
commit e39b89efc3
2 changed files with 11 additions and 4 deletions

View File

@ -665,6 +665,8 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
// regular function
else {
Function* function = addGlobalFunction(scope, tok, argStart, funcStart);
if (!function)
_tokenizer->syntaxError(tok);
function->retFuncPtr = retFuncPtr;
// global functions can't be const but we have tests that are
@ -692,10 +694,8 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
}
// syntax error?
if (!scope) {
scope = old_scope;
break;
}
if (!scope)
_tokenizer->syntaxError(tok);
}
// function prototype?
else if (scopeBegin->str() == ";") {

View File

@ -1938,6 +1938,13 @@ private:
{
ASSERT_THROW(GET_SYMBOL_DB("class Foo {}; class Bar : public Foo"), InternalError);
}
{
ASSERT_THROW(GET_SYMBOL_DB("YY_DECL { switch (yy_act) {\n"
" case 65: YY_BREAK\n"
" case YY_STATE_EOF(block):\n"
" yyterminate(); \n"
"} }"), InternalError); // #5663
}
}
void findFunction1() {