Fixed #5842: remove C99 static keyword between [] in tokenizer.
This commit is contained in:
parent
be9a566d48
commit
90c1016c74
|
@ -1241,7 +1241,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
|
|||
if (_settings->debugwarnings && errorlogger) {
|
||||
std::list<const Token *> callstack(1, tok);
|
||||
errorlogger->reportErr(ErrorLogger::ErrorMessage(callstack, &tokenlist, Severity::debug, "debug",
|
||||
"Failed to instantiate template. The checking continues anyway.", false));
|
||||
"Failed to instantiate template. The checking continues anyway.", false));
|
||||
}
|
||||
if (typeForNewName.empty())
|
||||
continue;
|
||||
|
|
|
@ -1519,7 +1519,7 @@ void Tokenizer::simplifyTypedef()
|
|||
void Tokenizer::simplifyMulAndParens()
|
||||
{
|
||||
if (!list.front())
|
||||
return;
|
||||
return;
|
||||
for (Token *tok = list.front()->tokAt(3); tok; tok = tok->next()) {
|
||||
if (tok->isName()) {
|
||||
//fix ticket #2784 - improved by ticket #3184
|
||||
|
@ -9248,7 +9248,7 @@ void Tokenizer::simplifyAttribute()
|
|||
}
|
||||
}
|
||||
|
||||
// Remove "volatile", "inline", "register", "restrict", "override", "final" and "constexpr"
|
||||
// Remove "volatile", "inline", "register", "restrict", "override", "final", "static" and "constexpr"
|
||||
// "restrict" keyword
|
||||
// - New to 1999 ANSI/ISO C standard
|
||||
// - Not in C++ standard yet
|
||||
|
@ -9265,6 +9265,11 @@ void Tokenizer::simplifyKeyword()
|
|||
while (tok->str() == "restrict") {
|
||||
tok->deleteThis();
|
||||
}
|
||||
|
||||
// simplify static keyword:
|
||||
// void foo( int [ static 5 ] ); ==> void foo( int [ 5 ] );
|
||||
if (Token::Match(tok, "[ static "))
|
||||
tok->deleteNext();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -214,6 +214,7 @@ private:
|
|||
TEST_CASE(simplifyKnownVariablesFunctionCalls); // Function calls (don't assume pass by reference)
|
||||
TEST_CASE(simplifyKnownVariablesReturn); // 3500 - return
|
||||
TEST_CASE(simplifyExternC);
|
||||
TEST_CASE(simplifyKeyword); // #5842 - remove C99 static keyword between []
|
||||
|
||||
TEST_CASE(varid1);
|
||||
TEST_CASE(varid2);
|
||||
|
@ -6580,6 +6581,13 @@ private:
|
|||
ASSERT_EQUALS("if ( ! ! x ) { ; }", actual);
|
||||
}
|
||||
|
||||
void simplifyKeyword() {
|
||||
const char code[] = "void f (int a [ static 5] );";
|
||||
|
||||
const std::string actual(tokenizeAndStringify(code, true));
|
||||
|
||||
ASSERT_EQUALS("void f ( int a [ 5 ] ) ;", actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* tokenize "signed i" => "signed int i"
|
||||
|
|
Loading…
Reference in New Issue