#Fixed 5485: Wrong simplification of numbers like 1e+007 to 1e+007.0
This commit is contained in:
parent
3275881056
commit
031020ae4a
|
@ -6525,10 +6525,8 @@ bool Tokenizer::simplifyKnownVariablesGetData(unsigned int varid, Token **_tok2,
|
|||
valueIsPointer = true;
|
||||
}
|
||||
|
||||
// float value should contain a "."
|
||||
else if (tok2->tokAt(2)->isNumber() &&
|
||||
floatvar &&
|
||||
value.find(".") == std::string::npos) {
|
||||
// Add a '.0' to a decimal value and therefore convert it to an floating point number.
|
||||
else if (MathLib::isDec(tok2->tokAt(2)->str()) && floatvar) {
|
||||
value += ".0";
|
||||
}
|
||||
|
||||
|
|
|
@ -3179,6 +3179,19 @@ private:
|
|||
" return a;"
|
||||
"}";
|
||||
ASSERT_EQUALS("double f ( ) { return 0.0 ; }", tokenizeAndStringify(code2,true));
|
||||
|
||||
// Ticket #5485
|
||||
const char code3[] = "void f() {"
|
||||
" double a = 1e+007;\n"
|
||||
" std::cout << a;\n"
|
||||
"}";
|
||||
ASSERT_EQUALS("void f ( ) {\nstd :: cout << 1e+007 ;\n}", tokenizeAndStringify(code3,true));
|
||||
|
||||
const char code4[] = "void f() {"
|
||||
" double a = 1;\n"
|
||||
" std::cout << a;\n"
|
||||
"}";
|
||||
ASSERT_EQUALS("void f ( ) {\nstd :: cout << 1.0 ;\n}", tokenizeAndStringify(code4,true));
|
||||
}
|
||||
|
||||
void simplifyKnownVariablesFunctionCalls() {
|
||||
|
|
Loading…
Reference in New Issue