diff --git a/lib/library.cpp b/lib/library.cpp index 5460e1c0c..ac29fad9a 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -635,7 +635,7 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const const Token *funcname = end->linkAt(-2)->previous(); const Token *start = funcname; - if (funcname && Token::Match(funcname->tokAt(-3),"( * %name% )")) { + if (Token::Match(funcname->tokAt(-3),"( * %name% )")) { funcname = funcname->previous(); start = funcname->tokAt(-3); } else if (funcname->isName()) { diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 07a0b2ae8..82160233b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7567,9 +7567,11 @@ void Tokenizer::simplifyEnum() //jump back once, see the comment at the end of the function goback = false; tok = tok->previous(); + if (!tok) + break; } - if (tok && tok->next() && + if (tok->next() && (!tok->previous() || (tok->previous()->str() != "enum")) && Token::Match(tok, "class|struct|namespace")) { className = tok->next()->str();