Fixed #5069 (sizeof(void) when variable name is override)
This commit is contained in:
parent
5641833cdb
commit
44559a1fb2
|
@ -9246,7 +9246,7 @@ void Tokenizer::simplifyKeyword()
|
|||
|
||||
if (_settings->standards.cpp >= Standards::CPP11) {
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
while (Token::Match(tok, "constexpr|override")) {
|
||||
while (tok->str() == "constexpr") {
|
||||
tok->deleteThis();
|
||||
}
|
||||
|
||||
|
@ -9255,6 +9255,13 @@ void Tokenizer::simplifyKeyword()
|
|||
// struct name final { }; <- struct is final
|
||||
if (Token::Match(tok, ") final [{;]") || Token::Match(tok, "%type% final [:{]"))
|
||||
tok->deleteNext();
|
||||
|
||||
// override
|
||||
// void f() override;
|
||||
else if (Token::Match(tok, ") override [{;]"))
|
||||
tok->deleteNext();
|
||||
else if (Token::Match(tok, ") const override [{;]"))
|
||||
tok->next()->deleteNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -447,6 +447,7 @@ private:
|
|||
|
||||
TEST_CASE(simplifyArrayAddress); // Replace "&str[num]" => "(str + num)"
|
||||
TEST_CASE(simplifyCharAt);
|
||||
TEST_CASE(simplifyOverride); // ticket #5069
|
||||
}
|
||||
|
||||
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Unspecified) {
|
||||
|
@ -8237,6 +8238,16 @@ private:
|
|||
ASSERT_EQUALS("int evallex ( ) { int c ; int t ; do { c = macroid ( c ) ; if ( c == EOF_CHAR || c == '\n' ) { } t = type [ c ] ; } while ( t == LET && catenate ( ) ) ; }",
|
||||
tok(code, true));
|
||||
}
|
||||
|
||||
void simplifyOverride() { // ticket #5069
|
||||
const char code[] = "void fun() {\n"
|
||||
" unsigned char override[] = {0x01, 0x02};\n"
|
||||
" doSomething(override, sizeof(override));\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("void fun ( ) { char override [ 2 ] = { 1 , 2 } ; doSomething ( override , 2 ) ; }",
|
||||
tok(code, true));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSimplifyTokens)
|
||||
|
|
Loading…
Reference in New Issue