Skip to content

Commit c7ffc37

Browse files
Merge pull request #156 from goblint/issue_136
Add option `silenceLongDoubleWarning`
2 parents 13efd21 + 8095737 commit c7ffc37

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/frontc/cabs2cil.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ let continueOnError = true
6363
(** Turn on tranformation that forces correct parameter evaluation order *)
6464
let forceRLArgEval = ref false
6565

66+
(** By default, we warn as large constants cannot be appropriately represented as OCaml floats.
67+
This can be set to true by tools that are aware of this problem and only use the string component of CReal
68+
to avoid emitting warnings that are spurious in that context. *)
69+
let silenceLongDoubleWarning = ref false
70+
6671
(** Leave a certain global alone. Use a negative number to disable. *)
6772
let nocil: int ref = ref (-1)
6873

@@ -3706,7 +3711,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
37063711
else
37073712
str, FDouble
37083713
in
3709-
if kind = FLongDouble || kind = FFloat128 then
3714+
if (kind = FLongDouble || kind = FFloat128) && not !silenceLongDoubleWarning then
37103715
(* We only have 64-bit values in Ocaml *)
37113716
E.log "treating %a constant %s as double constant at %a (only relevant if first argument of CReal is used).\n"
37123717
d_fkind kind str d_loc !currentLoc;

src/frontc/cabs2cil.mli

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ val convFile: Cabs.file -> Cil.file
4141
(** Turn on tranformation that forces correct parameter evaluation order *)
4242
val forceRLArgEval: bool ref
4343

44+
(** By default, we warn as large constants cannot be appropriately represented as OCaml floats.
45+
This can be set to true by tools that are aware of this problem and only use the string component of CReal
46+
to avoid emitting warnings that are spurious in that context. *)
47+
val silenceLongDoubleWarning: bool ref
48+
4449
(** Set this integer to the index of the global to be left in CABS form. Use
4550
-1 to disable *)
4651
val nocil: int ref

0 commit comments

Comments
 (0)