From eb1c048d2ae96fa57c2088146b1342b4d93f9a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 3 Jan 2015 21:35:03 +0100 Subject: [PATCH] Tokenizer: Fix wrong simplification when checking linux kernel --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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