#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;
|
valueIsPointer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// float value should contain a "."
|
// Add a '.0' to a decimal value and therefore convert it to an floating point number.
|
||||||
else if (tok2->tokAt(2)->isNumber() &&
|
else if (MathLib::isDec(tok2->tokAt(2)->str()) && floatvar) {
|
||||||
floatvar &&
|
|
||||||
value.find(".") == std::string::npos) {
|
|
||||||
value += ".0";
|
value += ".0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3179,6 +3179,19 @@ private:
|
||||||
" return a;"
|
" return a;"
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS("double f ( ) { return 0.0 ; }", tokenizeAndStringify(code2,true));
|
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() {
|
void simplifyKnownVariablesFunctionCalls() {
|
||||||
|
|
Loading…
Reference in New Issue