File tree 3 files changed +40
-0
lines changed
3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ // These need to be constant-folded at compile time
2
+
3
+ #define C1 (int) ( 0. / 1. + 0.5)
4
+ #define C2 (int) ( 1. / 1. + 0.5)
5
+
6
+ int nondet_int ();
7
+
8
+ int main (void )
9
+ {
10
+ int i = nondet_int ();
11
+
12
+ switch (i )
13
+ {
14
+ case C1 :
15
+ break ;
16
+
17
+ case C2 :
18
+ break ;
19
+
20
+ default :
21
+ break ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
Original file line number Diff line number Diff line change 24
24
#include < util/simplify_expr.h>
25
25
#include < util/string_constant.h>
26
26
27
+ #include < goto-programs/adjust_float_expressions.h>
28
+
27
29
#include " builtin_factory.h"
28
30
#include " c_typecast.h"
29
31
#include " c_qualifiers.h"
@@ -3372,6 +3374,13 @@ void c_typecheck_baset::typecheck_side_effect_assignment(
3372
3374
3373
3375
void c_typecheck_baset::make_constant (exprt &expr)
3374
3376
{
3377
+ // Floating-point expressions may require a rounding mode.
3378
+ // The compile-time rounding mode may differ from the
3379
+ // run-time rounding mode.
3380
+ const auto rounding_mode =
3381
+ from_integer (config.ansi_c .rounding_mode , signed_int_type ());
3382
+ adjust_float_expressions (expr, rounding_mode);
3383
+
3375
3384
simplify (expr, *this );
3376
3385
3377
3386
if (!expr.is_constant () &&
You can’t perform that action at this time.
0 commit comments