Fixed #8531 (false positive: (style) The function 'foo' overrides a function in a base class but is not marked with a 'override' specifier.)

This commit is contained in:
Daniel Marjamäki 2018-04-27 21:49:18 +02:00
parent 25599a76a7
commit e6a37ec0b7
2 changed files with 1 additions and 19 deletions

View File

@ -4167,7 +4167,7 @@ void Tokenizer::removeMacrosInGlobalScope()
if (tok->str() == "(") {
tok = tok->link();
if (Token::Match(tok, ") %type% {") &&
!Token::Match(tok->next(), "const|namespace|class|struct|union|noexcept"))
!Token::Match(tok->next(), "const|namespace|class|struct|union|noexcept|override|final"))
tok->deleteNext();
}

View File

@ -4042,24 +4042,6 @@ private:
ASSERT_EQUALS("void f ( int a [ 5 ] ) ;", tokenizeAndStringify(code));
}
{
const char in1[] = "class Base {\n"
" virtual int test() = 0;\n"
"};\n"
"class Derived : public Base {\n"
" virtual int test() override final {\n"
" for( int Index ( 0 ); Index < 16; ++ Index) { int stub = 0; }\n"
" }\n"
"};";
const char out1[] = "class Base {\n"
"virtual int test ( ) = 0 ;\n"
"} ;\n"
"class Derived : public Base {\n"
"virtual int test ( ) {\n"
"for ( int Index ( 0 ) ; Index < 16 ; ++ Index ) { int stub ; stub = 0 ; }\n"
"}\n"
"} ;";
ASSERT_EQUALS(out1, tokenizeAndStringify(in1));
const char in4 [] = "struct B final : A { void foo(); };";
const char out4 [] = "struct B : A { void foo ( ) ; } ;";
ASSERT_EQUALS(out4, tokenizeAndStringify(in4));