From 48e194dc56bce3f55f0367c0c71092053539e00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 10 Feb 2013 23:54:15 +0100 Subject: [PATCH] Fixed #4572 (Analysis failed: sizeof final) --- lib/tokenize.cpp | 8 +++++++- test/testsimplifytokens.cpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c422b84a1..fd1c2b814 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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(); } } } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 0e878ca6f..7c59ee280 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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"));