Skip to content

Commit 83aeddd

Browse files
author
Daniel Kroening
committed
added __builtin_isinf_sign
1 parent 87d467e commit 83aeddd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/ansi-c/c_typecheck_expr.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,30 @@ exprt c_typecheck_baset::do_special_functions(
23522352

23532353
return typecast_exprt::conditional_cast(isinf_expr, expr.type());
23542354
}
2355+
else if(identifier == "__builtin_isinf_sign")
2356+
{
2357+
if(expr.arguments().size() != 1)
2358+
{
2359+
err_location(f_op);
2360+
error() << identifier << " expects one operand" << eom;
2361+
throw 0;
2362+
}
2363+
2364+
// returns 1 for +inf and -1 for -inf, and 0 otherwise
2365+
2366+
const exprt &fp_value = expr.arguments().front();
2367+
2368+
isinf_exprt isinf_expr(fp_value);
2369+
isinf_expr.add_source_location() = source_location;
2370+
2371+
return if_exprt(
2372+
isinf_exprt(fp_value),
2373+
if_exprt(
2374+
sign_exprt(fp_value),
2375+
from_integer(-1, expr.type()),
2376+
from_integer(1, expr.type())),
2377+
from_integer(0, expr.type()));
2378+
}
23552379
else if(identifier==CPROVER_PREFIX "isnormalf" ||
23562380
identifier==CPROVER_PREFIX "isnormald" ||
23572381
identifier==CPROVER_PREFIX "isnormalld")

0 commit comments

Comments
 (0)