This commit is contained in:
parent
c4fe5ac8b7
commit
ed5532c2a7
|
@ -888,10 +888,16 @@ namespace {
|
|||
if (!after)
|
||||
throw InternalError(tok, "Failed to simplify typedef. Is the code valid?");
|
||||
|
||||
const Token* const tok4 = useAfterVarRange ? insertTokens(after->previous(), mRangeAfterVar)->next() : tok3->next();
|
||||
Token* const tok4 = useAfterVarRange ? insertTokens(after->previous(), mRangeAfterVar)->next() : tok3->next();
|
||||
|
||||
tok->deleteThis();
|
||||
|
||||
// Unsplit variable declarations
|
||||
if (Token::Match(tok4->previous(), "] ; %name% = {") && tok4->isSplittedVarDeclEq()) {
|
||||
tok4->deleteNext();
|
||||
tok4->deleteThis();
|
||||
}
|
||||
|
||||
// Set links
|
||||
std::stack<Token*> brackets;
|
||||
for (; tok != tok4; tok = tok->next()) {
|
||||
|
|
|
@ -67,6 +67,7 @@ private:
|
|||
TEST_CASE(carray1);
|
||||
TEST_CASE(carray2);
|
||||
TEST_CASE(carray3);
|
||||
TEST_CASE(carray4);
|
||||
TEST_CASE(cdonotreplace1);
|
||||
TEST_CASE(cppfp1);
|
||||
TEST_CASE(Generic1);
|
||||
|
@ -472,6 +473,13 @@ private:
|
|||
ASSERT_EQUALS("int ( * p ) [ 3 ] [ 2 ] [ 1 ] ;", simplifyTypedef(code));
|
||||
}
|
||||
|
||||
void carray4() {
|
||||
const char* code{};
|
||||
code = "typedef int arr[12];\n" // #12019
|
||||
"void foo() { arr temp = {0}; }\n";
|
||||
ASSERT_EQUALS("void foo ( ) { int temp [ 12 ] = { 0 } ; }", tok(code));
|
||||
}
|
||||
|
||||
void cdonotreplace1() {
|
||||
const char code[] = "typedef int t;\n"
|
||||
"int* t;";
|
||||
|
@ -1869,7 +1877,7 @@ private:
|
|||
"}";
|
||||
|
||||
// The expected tokens..
|
||||
const char expected2[] = "void f ( ) { char a [ 256 ] ; a = { 0 } ; char b [ 256 ] ; b = { 0 } ; }";
|
||||
const char expected2[] = "void f ( ) { char a [ 256 ] = { 0 } ; char b [ 256 ] = { 0 } ; }";
|
||||
ASSERT_EQUALS(expected2, tok(code2, false, cppcheck::Platform::Type::Native, false));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
|
|
Loading…
Reference in New Issue