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:
parent
25599a76a7
commit
e6a37ec0b7
|
@ -4167,7 +4167,7 @@ void Tokenizer::removeMacrosInGlobalScope()
|
||||||
if (tok->str() == "(") {
|
if (tok->str() == "(") {
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
if (Token::Match(tok, ") %type% {") &&
|
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();
|
tok->deleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4042,24 +4042,6 @@ private:
|
||||||
ASSERT_EQUALS("void f ( int a [ 5 ] ) ;", tokenizeAndStringify(code));
|
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 in4 [] = "struct B final : A { void foo(); };";
|
||||||
const char out4 [] = "struct B : A { void foo ( ) ; } ;";
|
const char out4 [] = "struct B : A { void foo ( ) ; } ;";
|
||||||
ASSERT_EQUALS(out4, tokenizeAndStringify(in4));
|
ASSERT_EQUALS(out4, tokenizeAndStringify(in4));
|
||||||
|
|
Loading…
Reference in New Issue