From a6d96f5b72e3cd30225fb046374d565149f41cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 15 Jan 2012 14:33:53 +0100 Subject: [PATCH] Fixed #3496 (false positive: syntax error) --- lib/templatesimplifier.cpp | 2 +- test/testtokenize.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 0199ceebc..82a1696c8 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -76,7 +76,7 @@ const Token* TemplateSimplifier::hasComplicatedSyntaxErrorsInTemplates(Token *to // check for more complicated syntax errors when using templates.. for (const Token *tok = tokens; tok; tok = tok->next()) { // skip executing scopes.. - if (Token::Match(tok, ") const| {") || Token::Match(tok, "[,=] {")) { + if (Token::simpleMatch(tok, ") {") || Token::Match(tok, ") %var% {") || Token::Match(tok, "[,=] {")) { while (tok->str() != "{") tok = tok->next(); tok = tok->link(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 96f550c82..4cf266cf5 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -598,8 +598,13 @@ private: ASSERT_EQUALS("( X && Y )", tokenizeAndStringify("(X&&Y)")); } - void tokenize19() { // #3006 (segmentation fault) + void tokenize19() { + // #3006 - added hasComplicatedSyntaxErrorsInTemplates to avoid segmentation fault tokenizeAndStringify("x < () <"); + + // #3496 - make sure hasComplicatedSyntaxErrorsInTemplates works + ASSERT_EQUALS("void a ( Fred * f ) { for ( ; n < f . x ( ) ; ) { } }", + tokenizeAndStringify("void a(Fred* f) MACRO { for (;n < f->x();) {} }")); } void tokenize20() { // replace C99 _Bool => bool