Fixed #8818 (AST broken: restrict)

This commit is contained in:
Daniel Marjamäki 2018-11-02 20:28:49 +01:00
parent 614a252704
commit e7d61f399a
2 changed files with 7 additions and 8 deletions

View File

@ -9084,18 +9084,16 @@ void Tokenizer::simplifyKeyword()
tok->deleteThis(); tok->deleteThis();
} }
if (isC() && mSettings->standards.c >= Standards::C99) {
if (mSettings->standards.c >= Standards::C99) {
while (tok->str() == "restrict") { while (tok->str() == "restrict") {
tok->deleteThis(); tok->deleteThis();
} }
}
// simplify static keyword: // simplify static keyword:
// void foo( int [ static 5 ] ); ==> void foo( int [ 5 ] ); // void foo( int [ static 5 ] ); ==> void foo( int [ 5 ] );
if (Token::Match(tok, "[ static %num%")) { if (Token::Match(tok, "[ static %num%")) {
tok->deleteNext(); tok->deleteNext();
} }
}
if (mSettings->standards.c >= Standards::C11) { if (mSettings->standards.c >= Standards::C11) {
while (tok->str() == "_Atomic") { while (tok->str() == "_Atomic") {

View File

@ -3280,6 +3280,7 @@ private:
ASSERT_EQUALS("int * p ;", tok("int * restrict p;", "test.c")); ASSERT_EQUALS("int * p ;", tok("int * restrict p;", "test.c"));
ASSERT_EQUALS("int * * p ;", tok("int * restrict * p;", "test.c")); 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("void foo ( float * a , float * b ) ;", tok("void foo(float * restrict a, float * restrict b);", "test.c"));
ASSERT_EQUALS("void foo ( int restrict ) ;", tok("void foo(int restrict);"));
ASSERT_EQUALS("int * p ;", tok("typedef int * __restrict__ rint; rint p;", "test.c")); ASSERT_EQUALS("int * p ;", tok("typedef int * __restrict__ rint; rint p;", "test.c"));
// don't remove struct members: // don't remove struct members: