template simplifier: fix missing instantiation (#1627)

This commit is contained in:
IOBYTE 2019-01-26 01:08:54 -05:00 committed by Daniel Marjamäki
parent 8078890b1b
commit 68bbe15116
2 changed files with 11 additions and 6 deletions

View File

@ -1369,8 +1369,12 @@ void TemplateSimplifier::expandTemplate(
continue;
}
if (inTemplateDefinition) {
if (!endOfTemplateDefinition && tok3->str() == "{")
endOfTemplateDefinition = tok3->link();
if (!endOfTemplateDefinition) {
if (isVariable)
endOfTemplateDefinition = Token::findsimplematch(tok3, ";");
else if (tok3->str() == "{")
endOfTemplateDefinition = tok3->link();
}
if (tok3 == endOfTemplateDefinition) {
inTemplateDefinition = false;
startOfTemplateDeclaration = nullptr;
@ -1532,7 +1536,7 @@ void TemplateSimplifier::expandTemplate(
addNamespace(templateDeclaration, tok3);
}
mTokenList.addtoken(newName, tok3->linenr(), tok3->fileIndex());
} else if (!Token::Match(tok3->next(), ":|{"))
} else if (!Token::Match(tok3->next(), ":|{|="))
tok3->str(newName);
continue;
}

View File

@ -1934,14 +1934,15 @@ private:
"long f2 = fib<2>;\n"
"long f3 = fib<3>;";
const char act[] = "const long fib<2> = fib < 1 > + fib < 0 > ; "
"const long fib<3> = fib < 2 > + fib < 1 > ; "
"const long fib<0> = 0 ; "
"const long fib<1> = 1 ; "
"long f0 ; f0 = fib<0> ; "
"long f1 ; f1 = fib<1> ; "
"long f2 ; f2 = fib<2> ; "
"long f3 ; f3 = fib < 3 > ;";
const char exp[] = "const long fib<3> = fib<2> + fib<1> ; "
"const long fib<2> = fib<1> + fib<0> ; "
"long f3 ; f3 = fib<3> ;";
const char exp[] = "const long fib<2> = fib<1> + fib<0> ; "
"const long fib<3> = fib<2> + fib<1> ; "
"const long fib<0> = 0 ; "
"const long fib<1> = 1 ; "
"long f0 ; f0 = fib<0> ; "