From bee4608b27efb2d50ccc837d8c8829376df44237 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 18 Apr 2010 09:13:55 +0200 Subject: [PATCH] Fixed #1613 (False -s positive: Template instantiation hides typedef with same name) --- lib/tokenize.cpp | 3 +++ test/testsimplifytokens.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 96b3ff3ec..4545f7ac9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -495,6 +495,9 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name) } else if (tok->previous()->str() == ">") { + if (!Token::Match(tok->tokAt(-2), "%type%")) + return false; + duplicateTypedefError(*tokPtr, name, "Template instantiation"); *tokPtr = end->link(); return true; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index f61f95919..660811d61 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -183,6 +183,7 @@ private: TEST_CASE(simplifyTypedef42); // ticket #1506 TEST_CASE(simplifyTypedef43); // ticket #1588 TEST_CASE(simplifyTypedef44); + TEST_CASE(simplifyTypedef45); // ticket #1613 TEST_CASE(reverseArraySyntax) TEST_CASE(simplify_numeric_condition) @@ -3877,6 +3878,18 @@ private: } } + void simplifyTypedef45() + { + // ticket # 1613 + const char code[] = "void fn() {\n" + " typedef foo<> bar;\n" + " while (0 > bar(1)) {}\n" + "}"; + + checkSimplifyTypedef(code); + ASSERT_EQUALS("", errout.str()); + } + void reverseArraySyntax() { ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));