Skip to content

Commit ad19f19

Browse files
author
Daniel Kroening
committed
added __builtin_isinf_sign
1 parent 80e17f5 commit ad19f19

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,30 @@ exprt c_typecheck_baset::do_special_functions(
23102310

23112311
return typecast_exprt::conditional_cast(isinf_expr, expr.type());
23122312
}
2313+
else if(identifier == "__builtin_isinf_sign")
2314+
{
2315+
if(expr.arguments().size() != 1)
2316+
{
2317+
err_location(f_op);
2318+
error() << identifier << " expects one operand" << eom;
2319+
throw 0;
2320+
}
2321+
2322+
// returns 1 for +inf and -1 for -inf, and 0 otherwise
2323+
2324+
const exprt &fp_value = expr.arguments().front();
2325+
2326+
isinf_exprt isinf_expr(fp_value);
2327+
isinf_expr.add_source_location() = source_location;
2328+
2329+
return if_exprt(
2330+
isinf_exprt(fp_value),
2331+
if_exprt(
2332+
sign_exprt(fp_value),
2333+
from_integer(-1, expr.type()),
2334+
from_integer(1, expr.type())),
2335+
from_integer(0, expr.type()));
2336+
}
23132337
else if(identifier==CPROVER_PREFIX "isnormalf" ||
23142338
identifier==CPROVER_PREFIX "isnormald" ||
23152339
identifier==CPROVER_PREFIX "isnormalld" ||

0 commit comments

Comments
 (0)