From 71ba513bdb84d1eb195c7f5b404397c606ffe86a Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Fri, 26 Jan 2018 22:06:07 +0100 Subject: [PATCH] Ticket #8361: Fix false positive in Tokenizer::findGarbageCode. (#1061) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6fb2544c7..e700446e4 100755 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8413,7 +8413,7 @@ const Token * Tokenizer::findGarbageCode() const tok = tok->next()->findClosingBracket(); if (!tok) return tok1; - if (!Token::Match(tok, ">|>> %name%")) + if (!Token::Match(tok, ">|>> ::| %name%")) return tok->next() ? tok->next() : tok1; } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index eec13033d..03d698950 100755 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -73,6 +73,7 @@ private: TEST_CASE(tokenize32); // #5884 (fsanitize=undefined: left shift of negative value -10000 in lib/templatesimplifier.cpp:852:46) TEST_CASE(tokenize33); // #5780 Various crashes on valid template code TEST_CASE(tokenize34); // #8031 + TEST_CASE(tokenize35); // #8361 TEST_CASE(validate); @@ -841,6 +842,11 @@ private: } } + void tokenize35() { // #8361 + tokenizeAndStringify("typedef int CRCWord; " + "template ::CRCWord const Compute(T const t) { return 0; }"); + } + void validate() { // C++ code in C file ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,false,Settings::Native,"test.c"), InternalError);