diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 06077fb23..83a5e8a29 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2457,8 +2457,12 @@ static bool isInitList(const Token *tok) void Tokenizer::setVarId() { // Clear all variable ids - for (Token *tok = list.front(); tok; tok = tok->next()) - tok->varId(0); + for (Token *tok = list.front(); tok; tok = tok->next()) { + if (tok->isName()) + tok->varId(0); + } + + setPodTypes(); // Variable declarations can't start with "return" etc. std::set notstart; @@ -10519,3 +10523,24 @@ void Tokenizer::reportError(const std::list& callstack, Severity:: else Check::reportError(errmsg); } + +void Tokenizer::setPodTypes() +{ + if (_settings) { + for (Token *tok = list.front(); tok; tok = tok->next()) { + if (!tok->isName()) + continue; + + // pod type + const struct Library::PodType *podType = _settings->library.podtype(tok->str()); + if (podType) { + const Token *prev = tok->previous(); + while (prev && prev->isName()) + prev = prev->previous(); + if (prev && !Token::Match(prev, ";|{|}|,|(")) + continue; + tok->isStandardType(true); + } + } + } +} diff --git a/lib/tokenize.h b/lib/tokenize.h index 83f78ff01..8edc0e451 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -798,6 +798,9 @@ private: return const_cast(startOfExecutableScope(const_cast(tok))); } + /** Set pod types */ + void setPodTypes(); + /** settings */ const Settings * _settings;