Fixed #4572 (Analysis failed: sizeof final)

This commit is contained in:
Daniel Marjamäki 2013-02-10 23:54:15 +01:00
parent b660cf89ef
commit 48e194dc56
2 changed files with 8 additions and 1 deletions

View File

@ -8626,9 +8626,15 @@ void Tokenizer::simplifyKeyword()
if (_settings->standards.cpp >= Standards::CPP11) {
for (Token *tok = list.front(); tok; tok = tok->next()) {
while (Token::Match(tok, "constexpr|override|final")) {
while (Token::Match(tok, "constexpr|override")) {
tok->deleteThis();
}
// final:
// void f() final; <- function is final
// struct name final { }; <- struct is final
if (Token::Match(tok, ") final [{;]") || Token::Match(tok, "%type% final [:{]"))
tok->deleteNext();
}
}
}

View File

@ -7729,6 +7729,7 @@ private:
ASSERT_EQUALS("int foo ( ) { }", tok("constexpr int foo() { }", true));
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() override ; };", true));
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() final ; };", true));
ASSERT_EQUALS("void f ( ) { int final [ 10 ] ; }", tok("void f() { int final[10]; }", true));
ASSERT_EQUALS("if ( a ) { }", tok("if ( likely ( a ) ) { }", true));
ASSERT_EQUALS("if ( a ) { }", tok("if ( unlikely ( a ) ) { }", true));
ASSERT_EQUALS("int * p ;", tok("int * __restrict p;", "test.c"));