diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0833b59f4..bfad7ac95 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4957,7 +4957,7 @@ void Tokenizer::simplifyUndefinedSizeArray() Token *tok2 = tok->next(); while (tok2 && tok2->str() == "*") tok2 = tok2->next(); - if (!Token::Match(tok2, "%var% [ ]")) + if (!Token::Match(tok2, "%var% [ ] ;|[")) continue; tok = tok2->previous(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index bd802fdd5..a4f34eb7f 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -4137,6 +4137,7 @@ private: ASSERT_EQUALS("int * * * x ;", tok("int * x [][];")); ASSERT_EQUALS("int * * * * x ;", tok("int * * x [][];")); ASSERT_EQUALS("void f ( int x [ ] , double y [ ] ) { }", tok("void f(int x[], double y[]) { }")); + ASSERT_EQUALS("int x [ 13 ] = { [ 11 ] = 2 , [ 12 ] = 3 } ;", tok("int x[] = {[11]=2, [12]=3};")); } void simplifyArrayAddress() { // ticket #3304