Skip to content

Commit 0aba53a

Browse files
author
Daniel Kroening
committed
added __builtin_isinf_sign
1 parent f876018 commit 0aba53a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,28 @@ exprt c_typecheck_baset::do_special_functions(
23162316
else
23172317
return isinf_expr; // bool
23182318
}
2319+
else if(identifier=="__builtin_isinf_sign")
2320+
{
2321+
if(expr.arguments().size()!=1)
2322+
{
2323+
err_location(f_op);
2324+
error() << identifier << " expects one operand" << eom;
2325+
throw 0;
2326+
}
2327+
2328+
// returns 1 for +inf and -1 for -inf, and 0 otherwise
2329+
2330+
const exprt &fp_value = expr.arguments().front();
2331+
2332+
isinf_exprt isinf_expr(fp_value);
2333+
isinf_expr.add_source_location()=source_location;
2334+
2335+
return if_exprt(
2336+
isinf_exprt(fp_value),
2337+
if_exprt(sign_exprt(fp_value),
2338+
from_integer(-1, expr.type()), from_integer(1, expr.type())),
2339+
from_integer(0, expr.type()));
2340+
}
23192341
else if(identifier==CPROVER_PREFIX "isnormalf" ||
23202342
identifier==CPROVER_PREFIX "isnormald" ||
23212343
identifier==CPROVER_PREFIX "isnormalld" ||

0 commit comments

Comments
 (0)