From c488af5255834d17e9daec84965ab0c6cebf5fd7 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 9 Jan 2024 13:21:42 +0100 Subject: [PATCH] added some missing standard checks [skip ci] --- lib/checktype.cpp | 2 +- lib/symboldatabase.cpp | 4 ++-- lib/tokenize.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 61a88e2cede3..78e47d433a29 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -133,7 +133,7 @@ void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, con { constexpr char id[] = "shiftTooManyBitsSigned"; - const bool cpp14 = mSettings->standards.cpp >= Standards::CPP14; + const bool cpp14 = mTokenizer->isCPP() && (mSettings->standards.cpp >= Standards::CPP14); std::string behaviour = "undefined"; if (cpp14) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 31e35e6d9fd8..63078ae52cf1 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1502,7 +1502,7 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars() // TODO: handle all C/C++ standards if (cppkeywords.count(tok->str()) > 0) continue; - if (mSettings.standards.cpp >= Standards::CPP20 && cpp20keywords.count(tok->str()) > 0) + if (tok->isCpp() && (mSettings.standards.cpp >= Standards::CPP20) && cpp20keywords.count(tok->str()) > 0) continue; std::string fstr = tok->str(); const Token* ftok = tok->previous(); @@ -4911,7 +4911,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con const Token *typestart = tok; // C++17 structured bindings - if (settings.standards.cpp >= Standards::CPP17 && Token::Match(tok, "auto &|&&| [")) { + if (tok->isCpp() && (settings.standards.cpp >= Standards::CPP17) && Token::Match(tok, "auto &|&&| [")) { const Token *typeend = Token::findsimplematch(typestart, "[")->previous(); for (tok = typeend->tokAt(2); Token::Match(tok, "%name%|,"); tok = tok->next()) { if (tok->varId()) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7986f65d5d0f..7e4773546f5a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6979,7 +6979,7 @@ void Tokenizer::simplifyVarDecl(const bool only_k_r_fpar) void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, const bool only_k_r_fpar) { - const bool isCPP11 = mSettings.standards.cpp >= Standards::CPP11; + const bool isCPP11 = isCPP() && (mSettings.standards.cpp >= Standards::CPP11); // Split up variable declarations.. // "int a=4;" => "int a; a=4;" @@ -8421,7 +8421,7 @@ void Tokenizer::findGarbageCode() const if (!Token::Match(tok->next(), "( !!)")) syntaxError(tok); if (tok->str() != "for") { - if (isGarbageExpr(tok->next(), tok->linkAt(1), mSettings.standards.cpp>=Standards::cppstd_t::CPP17)) + if (isGarbageExpr(tok->next(), tok->linkAt(1), isCPP() && (mSettings.standards.cpp>=Standards::cppstd_t::CPP17))) syntaxError(tok); } }