Fixed #7406 (Tokenizer::simplifyTypedef: array typedef used as template parameter) (#1257)

This commit is contained in:
IOBYTE 2018-05-22 11:31:58 -04:00 committed by amai2012
parent c73dc63537
commit fc1d62fd45
2 changed files with 11 additions and 1 deletions

View File

@ -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")

View File

@ -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<intvec> 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"