From fc1d62fd45f8796d447eabc809e9006ca1ab97ba Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Tue, 22 May 2018 11:31:58 -0400 Subject: [PATCH] Fixed #7406 (Tokenizer::simplifyTypedef: array typedef used as template parameter) (#1257) --- lib/tokenize.cpp | 2 +- test/testsimplifytypedef.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6bdba4982..39150f3ab 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1504,7 +1504,7 @@ void Tokenizer::simplifyTypedef() if (!tok2->next()) syntaxError(tok2); // can't recover so quit - if (!inCast && !inSizeof) + if (!inCast && !inSizeof && !inTemplate) tok2 = tok2->next(); if (tok2->str() == "const") diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index fbbe2fc5f..cc5cb871a 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -160,6 +160,7 @@ private: TEST_CASE(simplifyTypedef120); // ticket #8357 TEST_CASE(simplifyTypedef121); // ticket #5766 TEST_CASE(simplifyTypedef122); // segmentation fault + TEST_CASE(simplifyTypedef123); // ticket #7406 TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -2499,6 +2500,15 @@ private: ASSERT_EQUALS("", errout.str()); } + void simplifyTypedef123() { // ticket #7406 + const char code[] = "typedef int intvec[1];\n" + "Dummy y;"; + const char exp [] = "Dummy < int [ 1 ] > y ;"; + ASSERT_EQUALS(exp, tok(code, false)); + ASSERT_EQUALS("", errout.str()); + } + + void simplifyTypedefFunction1() { { const char code[] = "typedef void (*my_func)();\n"