Skip to content

Commit

Permalink
added some missing standard checks [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Jan 20, 2024
1 parent 1f5e943 commit c488af5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/checktype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;"
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit c488af5

Please sign in to comment.