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