From 6ae1533cb4a8b3b708c920a5a02687050363b602 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Sat, 5 Dec 2015 13:55:33 +0100 Subject: [PATCH] #7190 Cppcheck hangs with 100% CPU load in Tokenizer::simplifyAttribute (invalidcode). Call validate() once more in Tokenizer::simplifyTokenList1 to trigger invalid code exception --- lib/tokenize.cpp | 3 +++ test/testgarbage.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 438682de7..f6cb2aaa0 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3502,6 +3502,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // class Fred FINAL : Base { }; removeMacroInClassDef(); + // That call here fixes #7190 + validate(); + // remove __attribute__((?)) simplifyAttribute(); diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 97f977c7d..cd6e4d759 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -208,6 +208,7 @@ private: TEST_CASE(garbageCode157); // #7131 TEST_CASE(garbageCode158); // #3238 TEST_CASE(garbageCode159); // #7119 + TEST_CASE(garbageCode160); // #7190 TEST_CASE(garbageValueFlow); TEST_CASE(garbageSymbolDatabase); @@ -1248,7 +1249,11 @@ private: } void garbageCode159() { // #7119 - checkCode("({}typedef typename x;typename x!){({{}()})}"); // dont hang + checkCode("({}typedef typename x;typename x!){({{}()})}"); // don't hang + } + + void garbageCode160() { // #7190 + ASSERT_THROW(checkCode("f(a,b,c,d)float [ a[],d;int ] b[],c;{} "), InternalError); // don't hang }