Tokenizer: skip constant folding in normal token list for C code. In C++ code we should only fold constants in template arguments.

This commit is contained in:
Daniel Marjamäki 2016-02-06 17:25:51 +01:00
parent d25258359a
commit 42278dd133
1 changed files with 15 additions and 14 deletions

View File

@ -3584,22 +3584,23 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// Remove redundant parentheses
simplifyRedundantParentheses();
for (Token *tok = list.front(); tok; tok = tok->next())
while (TemplateSimplifier::simplifyNumericCalculations(tok))
;
// Handle templates..
simplifyTemplates();
// The simplifyTemplates have inner loops
if (_settings->terminated())
return false;
// Simplify templates.. sometimes the "simplifyTemplates" fail and
// then unsimplified function calls etc remain. These have the
// "wrong" syntax. So this function will just fix so that the
// syntax is corrected.
if (!isC()) {
// TODO: Only simplify template parameters
for (Token *tok = list.front(); tok; tok = tok->next())
while (TemplateSimplifier::simplifyNumericCalculations(tok))
;
// Handle templates..
simplifyTemplates();
// The simplifyTemplates have inner loops
if (_settings->terminated())
return false;
// sometimes the "simplifyTemplates" fail and then unsimplified
// function calls etc remain. These have the "wrong" syntax. So
// this function will just fix so that the syntax is corrected.
validate(); // #6847 - invalid code
TemplateSimplifier::cleanupAfterSimplify(list.front());
}