@@ -2255,7 +2255,7 @@ exprt c_typecheck_baset::do_special_functions(
2255
2255
isnan_exprt isnan_expr (expr.arguments ().front ());
2256
2256
isnan_expr.add_source_location ()=source_location;
2257
2257
2258
- return isnan_expr;
2258
+ return typecast_exprt::conditional_cast ( isnan_expr, expr. type ()) ;
2259
2259
}
2260
2260
else if (identifier==CPROVER_PREFIX " isfinitef" ||
2261
2261
identifier==CPROVER_PREFIX " isfinited" ||
@@ -2271,7 +2271,7 @@ exprt c_typecheck_baset::do_special_functions(
2271
2271
isfinite_exprt isfinite_expr (expr.arguments ().front ());
2272
2272
isfinite_expr.add_source_location ()=source_location;
2273
2273
2274
- return isfinite_expr;
2274
+ return typecast_exprt::conditional_cast ( isfinite_expr, expr. type ()) ;
2275
2275
}
2276
2276
else if (identifier==CPROVER_PREFIX " inf" ||
2277
2277
identifier==" __builtin_inf" )
@@ -2343,14 +2343,14 @@ exprt c_typecheck_baset::do_special_functions(
2343
2343
if (expr.arguments ().size ()!=1 )
2344
2344
{
2345
2345
err_location (f_op);
2346
- error () << " isinf expects one operand" << eom;
2346
+ error () << identifier << " expects one operand" << eom;
2347
2347
throw 0 ;
2348
2348
}
2349
2349
2350
2350
isinf_exprt isinf_expr (expr.arguments ().front ());
2351
2351
isinf_expr.add_source_location ()=source_location;
2352
2352
2353
- return isinf_expr;
2353
+ return typecast_exprt::conditional_cast ( isinf_expr, expr. type ()) ;
2354
2354
}
2355
2355
else if (identifier==CPROVER_PREFIX " isnormalf" ||
2356
2356
identifier==CPROVER_PREFIX " isnormald" ||
@@ -2359,14 +2359,23 @@ exprt c_typecheck_baset::do_special_functions(
2359
2359
if (expr.arguments ().size ()!=1 )
2360
2360
{
2361
2361
err_location (f_op);
2362
- error () << " isnormal expects one operand" << eom;
2362
+ error () << identifier << " expects one operand" << eom;
2363
+ throw 0 ;
2364
+ }
2365
+
2366
+ const exprt &fp_value = expr.arguments ()[0 ];
2367
+
2368
+ if (fp_value.type ().id () != ID_floatbv)
2369
+ {
2370
+ err_location (fp_value);
2371
+ error () << " non-floating-point argument for " << identifier << eom;
2363
2372
throw 0 ;
2364
2373
}
2365
2374
2366
2375
isnormal_exprt isnormal_expr (expr.arguments ().front ());
2367
2376
isnormal_expr.add_source_location ()=source_location;
2368
2377
2369
- return isnormal_expr;
2378
+ return typecast_exprt::conditional_cast ( isnormal_expr, expr. type ()) ;
2370
2379
}
2371
2380
else if (identifier==CPROVER_PREFIX " signf" ||
2372
2381
identifier==CPROVER_PREFIX " signd" ||
@@ -2378,14 +2387,14 @@ exprt c_typecheck_baset::do_special_functions(
2378
2387
if (expr.arguments ().size ()!=1 )
2379
2388
{
2380
2389
err_location (f_op);
2381
- error () << " sign expects one operand" << eom;
2390
+ error () << identifier << " expects one operand" << eom;
2382
2391
throw 0 ;
2383
2392
}
2384
2393
2385
2394
sign_exprt sign_expr (expr.arguments ().front ());
2386
2395
sign_expr.add_source_location ()=source_location;
2387
2396
2388
- return sign_expr;
2397
+ return typecast_exprt::conditional_cast ( sign_expr, expr. type ()) ;
2389
2398
}
2390
2399
else if (identifier==" __builtin_popcount" ||
2391
2400
identifier==" __builtin_popcountl" ||
0 commit comments