Tokenizer: Don't remove struct member in Tokenizer::simplifyKeyword()

This commit is contained in:
Daniel Marjamäki 2014-08-01 17:19:08 +02:00
parent f908959196
commit a943a0739a
2 changed files with 23 additions and 3 deletions

View File

@ -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) {

View File

@ -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() {