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/>
|
||||
<arg nr="1">
|
||||
<not-uninit/>
|
||||
<valid>0.0:</valid>
|
||||
</arg>
|
||||
</function>
|
||||
<!-- float sqrtf(float x); -->
|
||||
|
@ -228,6 +229,7 @@
|
|||
<leak-ignore/>
|
||||
<arg nr="1">
|
||||
<not-uninit/>
|
||||
<valid>0.0:</valid>
|
||||
</arg>
|
||||
</function>
|
||||
<!-- long double sqrtl(long double x); -->
|
||||
|
@ -239,6 +241,7 @@
|
|||
<leak-ignore/>
|
||||
<arg nr="1">
|
||||
<not-uninit/>
|
||||
<valid>0.0:</valid>
|
||||
</arg>
|
||||
</function>
|
||||
<!-- double complex csqrt(double complex x); -->
|
||||
|
|
|
@ -241,12 +241,6 @@ void CheckFunctions::checkMathFunctions()
|
|||
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
|
||||
else if (Token::Match(tok, "atan2|atan2f|atan2l ( %num% , %num% )")) {
|
||||
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 << sqrtl(-1) << std::endl;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Passing value -1 to sqrt() leads to implementation-defined result.\n"
|
||||
"[test.cpp:4]: (warning) Passing value -1 to sqrtf() leads to implementation-defined result.\n"
|
||||
"[test.cpp:5]: (warning) Passing value -1 to sqrtl() leads to implementation-defined result.\n", errout.str());
|
||||
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]: (error) Invalid sqrtf() argument nr 1. The value is -1 but the valid values are '0.0:'.\n"
|
||||
"[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:
|
||||
check("void foo()\n"
|
||||
|
|
Loading…
Reference in New Issue