From b801386ac8fd206cca25ea62b21c0ed6300bba24 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 4 Feb 2016 10:00:54 +0100 Subject: [PATCH] Fixed bug in Token::findClosingBracket() and broken unit test (#7277) --- lib/token.cpp | 6 ++++-- test/testtoken.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index c33c61c3c..c1a00f7b2 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -818,9 +818,11 @@ const Token * Token::findClosingBracket() const closing = closing->link(); if (!closing) return nullptr; // #6803 - } else if (Token::Match(closing, "}|]|)|;")) + } else if (Token::Match(closing, "}|]|)|;")) { + if (depth > 0) + return nullptr; break; - else if (closing->str() == "<") + } else if (closing->str() == "<") ++depth; else if (closing->str() == ">") { if (--depth == 0) diff --git a/test/testtoken.cpp b/test/testtoken.cpp index c9f6da8e2..f15f8b292 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -927,7 +927,7 @@ private: ASSERT(t != nullptr && t->str() == ">"); t = var.tokens()->tokAt(4)->findClosingBracket(); - ASSERT(t != nullptr && t->str() == ")"); + ASSERT(t == nullptr); } };