Move sqrt{,f,l} argument checks to cfg file (#1313)
This commit is contained in:
parent
788ad0fc1f
commit
30a8d953e3
|
@ -217,6 +217,7 @@
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
|
<valid>0.0:</valid>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
<!-- float sqrtf(float x); -->
|
<!-- float sqrtf(float x); -->
|
||||||
|
@ -228,6 +229,7 @@
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
|
<valid>0.0:</valid>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
<!-- long double sqrtl(long double x); -->
|
<!-- long double sqrtl(long double x); -->
|
||||||
|
@ -239,6 +241,7 @@
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
<not-uninit/>
|
<not-uninit/>
|
||||||
|
<valid>0.0:</valid>
|
||||||
</arg>
|
</arg>
|
||||||
</function>
|
</function>
|
||||||
<!-- double complex csqrt(double complex x); -->
|
<!-- double complex csqrt(double complex x); -->
|
||||||
|
|
|
@ -241,12 +241,6 @@ void CheckFunctions::checkMathFunctions()
|
||||||
mathfunctionCallWarning(tok); // case log(0)
|
mathfunctionCallWarning(tok); // case log(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sqrt( x ): if x is negative the result is undefined
|
|
||||||
else if (Token::Match(tok, "sqrt|sqrtf|sqrtl ( %num% )")) {
|
|
||||||
if (MathLib::isNegative(tok->strAt(2)))
|
|
||||||
mathfunctionCallWarning(tok);
|
|
||||||
}
|
|
||||||
// atan2 ( x , y): x and y can not be zero, because this is mathematically not defined
|
// atan2 ( x , y): x and y can not be zero, because this is mathematically not defined
|
||||||
else if (Token::Match(tok, "atan2|atan2f|atan2l ( %num% , %num% )")) {
|
else if (Token::Match(tok, "atan2|atan2f|atan2l ( %num% , %num% )")) {
|
||||||
if (MathLib::isNullValue(tok->strAt(2)) && MathLib::isNullValue(tok->strAt(4)))
|
if (MathLib::isNullValue(tok->strAt(2)) && MathLib::isNullValue(tok->strAt(4)))
|
||||||
|
|
|
@ -455,9 +455,9 @@ private:
|
||||||
" std::cout << sqrtf(-1) << std::endl;\n"
|
" std::cout << sqrtf(-1) << std::endl;\n"
|
||||||
" std::cout << sqrtl(-1) << std::endl;\n"
|
" std::cout << sqrtl(-1) << std::endl;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Passing value -1 to sqrt() leads to implementation-defined result.\n"
|
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid sqrt() argument nr 1. The value is -1 but the valid values are '0.0:'.\n"
|
||||||
"[test.cpp:4]: (warning) Passing value -1 to sqrtf() leads to implementation-defined result.\n"
|
"[test.cpp:4]: (error) Invalid sqrtf() argument nr 1. The value is -1 but the valid values are '0.0:'.\n"
|
||||||
"[test.cpp:5]: (warning) Passing value -1 to sqrtl() leads to implementation-defined result.\n", errout.str());
|
"[test.cpp:5]: (error) Invalid sqrtl() argument nr 1. The value is -1 but the valid values are '0.0:'.\n", errout.str());
|
||||||
|
|
||||||
// implementation-defined behaviour for "finite values of x<0" only:
|
// implementation-defined behaviour for "finite values of x<0" only:
|
||||||
check("void foo()\n"
|
check("void foo()\n"
|
||||||
|
|
Loading…
Reference in New Issue