Skip to content

Commit de903bf

Browse files
author
Daniel Kroening
committed
fx
1 parent 5d6f74c commit de903bf

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,10 +2195,11 @@ exprt c_typecheck_baset::do_special_functions(
21952195

21962196
return bswap_expr;
21972197
}
2198-
else if(identifier=="__builtin_fpclassify" ||
2199-
identifier==CPROVER_PREFIX "fpclassify")
2198+
else if(
2199+
identifier == "__builtin_fpclassify" ||
2200+
identifier == CPROVER_PREFIX "fpclassify")
22002201
{
2201-
if(expr.arguments().size()!=6)
2202+
if(expr.arguments().size() != 6)
22022203
{
22032204
err_location(f_op);
22042205
error() << identifier << " expects six arguments" << eom;
@@ -2210,28 +2211,33 @@ exprt c_typecheck_baset::do_special_functions(
22102211
// FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL and FP_ZERO.
22112212
// gcc expects this to be able to produce compile-time constants.
22122213

2213-
if(expr.arguments()[5].type().id()!=ID_floatbv)
2214+
const auto &arguments = expr.arguments();
2215+
const exprt &fp_value=arguments[5];
2216+
2217+
if(fp_value.type().id() != ID_floatbv)
22142218
{
2215-
err_location(expr.arguments()[5]);
2219+
err_location(fp_value);
22162220
error() << "non-floating-point argument for " << identifier << eom;
22172221
throw 0;
22182222
}
22192223

2220-
const auto &floatbv_type=to_floatbv_type(expr.arguments()[5].type());
2224+
const auto &floatbv_type = to_floatbv_type(fp_value.type());
22212225

2222-
const exprt zero=
2223-
ieee_floatt::zero(floatbv_type).to_expr();
2226+
const exprt zero = ieee_floatt::zero(floatbv_type).to_expr();
22242227

2225-
return
2226-
if_exprt(unary_predicate_exprt(ID_isnan, expr.arguments()[5]),
2227-
expr.arguments()[0],
2228-
if_exprt(unary_predicate_exprt(ID_isinf, expr.arguments()[5]),
2229-
expr.arguments()[1],
2230-
if_exprt(unary_predicate_exprt(ID_isnormal, expr.arguments()[5]),
2231-
expr.arguments()[2],
2232-
if_exprt(ieee_float_equal_exprt(expr.arguments()[5], zero),
2233-
expr.arguments()[4],
2234-
expr.arguments()[3])))); // subnormal
2228+
return if_exprt(
2229+
isnan_exprt(fp_value),
2230+
arguments[0],
2231+
if_exprt(
2232+
isinf_exprt(fp_value),
2233+
arguments[1],
2234+
if_exprt(
2235+
isnormal_exprt(fp_value),
2236+
arguments[2],
2237+
if_exprt(
2238+
ieee_float_equal_exprt(fp_value, zero),
2239+
arguments[4],
2240+
arguments[3])))); // subnormal
22352241
}
22362242
else if(identifier==CPROVER_PREFIX "isnanf" ||
22372243
identifier==CPROVER_PREFIX "isnand" ||

src/ansi-c/library/math.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ inline short _fdclass(float f) {
287287

288288
inline int __fpclassifyd(double d) {
289289
__CPROVER_HIDE:
290-
return __CPROVER_fpclassify(
291-
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
290+
return __CPROVER_fpclassify(
291+
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
292292
}
293293

294294
/* FUNCTION: __fpclassifyf */
@@ -300,8 +300,8 @@ inline int __fpclassifyd(double d) {
300300

301301
inline int __fpclassifyf(float f) {
302302
__CPROVER_HIDE:
303-
return __CPROVER_fpclassify(
304-
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, f);
303+
return __CPROVER_fpclassify(
304+
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, f);
305305
}
306306

307307
/* FUNCTION: __fpclassifyl */
@@ -313,8 +313,8 @@ inline int __fpclassifyf(float f) {
313313

314314
inline int __fpclassifyl(long double f) {
315315
__CPROVER_HIDE:
316-
return __CPROVER_fpclassify(
317-
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, f);
316+
return __CPROVER_fpclassify(
317+
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, f);
318318
}
319319

320320
/* FUNCTION: __fpclassify */
@@ -330,14 +330,14 @@ inline int __fpclassifyl(long double f) {
330330
#ifdef __APPLE__
331331
inline int __fpclassify(long double d) {
332332
__CPROVER_HIDE:
333-
return __CPROVER_fpclassify(
334-
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
333+
return __CPROVER_fpclassify(
334+
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
335335
}
336336
#else
337337
inline int __fpclassify(double d) {
338338
__CPROVER_HIDE:
339-
return __CPROVER_fpclassify(
340-
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
339+
return __CPROVER_fpclassify(
340+
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, d);
341341
}
342342
#endif
343343

0 commit comments

Comments
 (0)