Skip to content

Commit c488af5

Browse files
committed
added some missing standard checks [skip ci]
1 parent 1f5e943 commit c488af5

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/checktype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, con
133133
{
134134
constexpr char id[] = "shiftTooManyBitsSigned";
135135

136-
const bool cpp14 = mSettings->standards.cpp >= Standards::CPP14;
136+
const bool cpp14 = mTokenizer->isCPP() && (mSettings->standards.cpp >= Standards::CPP14);
137137

138138
std::string behaviour = "undefined";
139139
if (cpp14)

lib/symboldatabase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars()
15021502
// TODO: handle all C/C++ standards
15031503
if (cppkeywords.count(tok->str()) > 0)
15041504
continue;
1505-
if (mSettings.standards.cpp >= Standards::CPP20 && cpp20keywords.count(tok->str()) > 0)
1505+
if (tok->isCpp() && (mSettings.standards.cpp >= Standards::CPP20) && cpp20keywords.count(tok->str()) > 0)
15061506
continue;
15071507
std::string fstr = tok->str();
15081508
const Token* ftok = tok->previous();
@@ -4911,7 +4911,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
49114911
const Token *typestart = tok;
49124912

49134913
// C++17 structured bindings
4914-
if (settings.standards.cpp >= Standards::CPP17 && Token::Match(tok, "auto &|&&| [")) {
4914+
if (tok->isCpp() && (settings.standards.cpp >= Standards::CPP17) && Token::Match(tok, "auto &|&&| [")) {
49154915
const Token *typeend = Token::findsimplematch(typestart, "[")->previous();
49164916
for (tok = typeend->tokAt(2); Token::Match(tok, "%name%|,"); tok = tok->next()) {
49174917
if (tok->varId())

lib/tokenize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6979,7 +6979,7 @@ void Tokenizer::simplifyVarDecl(const bool only_k_r_fpar)
69796979

69806980
void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, const bool only_k_r_fpar)
69816981
{
6982-
const bool isCPP11 = mSettings.standards.cpp >= Standards::CPP11;
6982+
const bool isCPP11 = isCPP() && (mSettings.standards.cpp >= Standards::CPP11);
69836983

69846984
// Split up variable declarations..
69856985
// "int a=4;" => "int a; a=4;"
@@ -8421,7 +8421,7 @@ void Tokenizer::findGarbageCode() const
84218421
if (!Token::Match(tok->next(), "( !!)"))
84228422
syntaxError(tok);
84238423
if (tok->str() != "for") {
8424-
if (isGarbageExpr(tok->next(), tok->linkAt(1), mSettings.standards.cpp>=Standards::cppstd_t::CPP17))
8424+
if (isGarbageExpr(tok->next(), tok->linkAt(1), isCPP() && (mSettings.standards.cpp>=Standards::cppstd_t::CPP17)))
84258425
syntaxError(tok);
84268426
}
84278427
}

0 commit comments

Comments
 (0)