Tokenizer: Don't remove struct member in Tokenizer::simplifyKeyword()
This commit is contained in:
parent
f908959196
commit
a943a0739a
|
@ -9301,10 +9301,26 @@ void Tokenizer::simplifyAttribute()
|
|||
// - Not in C++ standard yet
|
||||
void Tokenizer::simplifyKeyword()
|
||||
{
|
||||
std::set<std::string> keywords;
|
||||
keywords.insert("volatile");
|
||||
keywords.insert("inline");
|
||||
keywords.insert("_inline");
|
||||
keywords.insert("__inline");
|
||||
keywords.insert("__forceinline");
|
||||
keywords.insert("register");
|
||||
keywords.insert("__restrict");
|
||||
keywords.insert("__restrict__");
|
||||
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
while (Token::Match(tok, "volatile|inline|_inline|__inline|__forceinline|register|__restrict|__restrict__")) {
|
||||
tok->deleteThis();
|
||||
}
|
||||
if (keywords.find(tok->str()) == keywords.end())
|
||||
continue;
|
||||
|
||||
// Don't remove struct members
|
||||
if (Token::Match(tok->previous(), "."))
|
||||
continue;
|
||||
|
||||
// Simplify..
|
||||
tok->deleteThis();
|
||||
}
|
||||
|
||||
if (_settings->standards.c >= Standards::C99) {
|
||||
|
|
|
@ -7621,6 +7621,10 @@ private:
|
|||
ASSERT_EQUALS("int * * p ;", tok("int * restrict * p;", "test.c"));
|
||||
ASSERT_EQUALS("void foo ( float * a , float * b ) ;", tok("void foo(float * restrict a, float * restrict b);", "test.c"));
|
||||
ASSERT_EQUALS("int * p ;", tok("typedef int * __restrict__ rint; rint p;", "test.c"));
|
||||
|
||||
// don't remove struct members:
|
||||
ASSERT_EQUALS("a = b . _inline ;", tok("a = b._inline;", true));
|
||||
|
||||
}
|
||||
|
||||
void simplifyCallingConvention() {
|
||||
|
|
Loading…
Reference in New Issue