* Fixed #9053 (simplifyTypedef: wrong simplification of '(const d)' when 'd' is a array) * fix whitespace
This commit is contained in:
parent
7c7ee66cf9
commit
40af889df0
|
@ -1241,7 +1241,8 @@ void Tokenizer::simplifyTypedef()
|
|||
// check for cast: (some_typedef) A or static_cast<some_typedef>(A)
|
||||
// todo: check for more complicated casts like: (const some_typedef *)A
|
||||
if ((tok2->previous()->str() == "(" && tok2->next()->str() == ")" && tok2->strAt(-2) != "sizeof") ||
|
||||
(tok2->previous()->str() == "<" && Token::simpleMatch(tok2->next(), "> (")))
|
||||
(tok2->previous()->str() == "<" && Token::simpleMatch(tok2->next(), "> (")) ||
|
||||
Token::Match(tok2->tokAt(-2), "( const %name% )"))
|
||||
inCast = true;
|
||||
|
||||
// check for template parameters: t<some_typedef> t1
|
||||
|
|
|
@ -165,6 +165,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef125); // #8749 - typedef char A[10]; p = new A[1];
|
||||
TEST_CASE(simplifyTypedef126); // ticket #5953
|
||||
TEST_CASE(simplifyTypedef127); // ticket #8878
|
||||
TEST_CASE(simplifyTypedef128); // ticket #9053
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -2551,6 +2552,17 @@ private:
|
|||
ASSERT_EQUALS(exp, tok(code, false));
|
||||
}
|
||||
|
||||
void simplifyTypedef128() { // #9053
|
||||
const char code[] = "typedef int d[4];\n"
|
||||
"void f() {\n"
|
||||
" dostuff((const d){1,2,3,4});\n"
|
||||
"}";
|
||||
const char exp [] = "void f ( ) { "
|
||||
"dostuff ( ( const int [ 4 ] ) { 1 , 2 , 3 , 4 } ) ; "
|
||||
"}";
|
||||
ASSERT_EQUALS(exp, tok(code, false));
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1() {
|
||||
{
|
||||
const char code[] = "typedef void (*my_func)();\n"
|
||||
|
|
Loading…
Reference in New Issue