Fixed #5842: remove C99 static keyword between [] in tokenizer.
This commit is contained in:
parent
be9a566d48
commit
90c1016c74
|
@ -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
|
// "restrict" keyword
|
||||||
// - New to 1999 ANSI/ISO C standard
|
// - New to 1999 ANSI/ISO C standard
|
||||||
// - Not in C++ standard yet
|
// - Not in C++ standard yet
|
||||||
|
@ -9265,6 +9265,11 @@ void Tokenizer::simplifyKeyword()
|
||||||
while (tok->str() == "restrict") {
|
while (tok->str() == "restrict") {
|
||||||
tok->deleteThis();
|
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(simplifyKnownVariablesFunctionCalls); // Function calls (don't assume pass by reference)
|
||||||
TEST_CASE(simplifyKnownVariablesReturn); // 3500 - return
|
TEST_CASE(simplifyKnownVariablesReturn); // 3500 - return
|
||||||
TEST_CASE(simplifyExternC);
|
TEST_CASE(simplifyExternC);
|
||||||
|
TEST_CASE(simplifyKeyword); // #5842 - remove C99 static keyword between []
|
||||||
|
|
||||||
TEST_CASE(varid1);
|
TEST_CASE(varid1);
|
||||||
TEST_CASE(varid2);
|
TEST_CASE(varid2);
|
||||||
|
@ -6580,6 +6581,13 @@ private:
|
||||||
ASSERT_EQUALS("if ( ! ! x ) { ; }", actual);
|
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"
|
* tokenize "signed i" => "signed int i"
|
||||||
|
|
Loading…
Reference in New Issue