aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cutil.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-07-29 09:15:36 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2016-07-29 09:15:36 +0200
commit21156a2fcf48764762c7f2209fa850024378d83a (patch)
treee56bb6ee6b8099b3520c4e97ccd1cd776ff9eb7a /cparser/Cutil.ml
parentc7832c32253cdc2123313731c7cbbace4fc8332c (diff)
downloadcompcert-kvx-21156a2fcf48764762c7f2209fa850024378d83a.tar.gz
compcert-kvx-21156a2fcf48764762c7f2209fa850024378d83a.zip
Classified all warnings and added various options.
Now each warning either has a name and can be turned on/off, made into an error,etc. or is a warning that always will be triggered. The message of the warnings are similar to the ones emited by gcc/clang and all fit into one line. Furthermore the diagnostics are now colored if colored output is available. Bug 18004
Diffstat (limited to 'cparser/Cutil.ml')
-rw-r--r--cparser/Cutil.ml18
1 files changed, 13 insertions, 5 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index 4b4e1b81..b19b1e4b 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -20,6 +20,11 @@ open C
open Env
open Machine
+
+(* Empty location *)
+
+let no_loc = ("", -1)
+
(* Set and Map structures over identifiers *)
module Ident = struct
@@ -478,7 +483,7 @@ let rec sizeof env t =
| Some s ->
match cautious_mul n s with
| Some sz -> Some sz
- | None -> error "sizeof(%a) overflows" Cprint.typ t'; Some 1
+ | None -> error no_loc "sizeof(%a) overflows" Cprint.typ t'; Some 1
end
| TFun(_, _, _, _) -> !config.sizeof_fun
| TNamed(_, _) -> sizeof env (unroll env t)
@@ -941,6 +946,13 @@ let valid_cast env tfrom tto =
| TUnion(s1, _), TUnion(s2, _) -> s1 = s2
| _, _ -> false
+(* Check that a cast from the first type to the second is an integer conversion *)
+
+let int_pointer_conversion env tfrom tto =
+ match unroll env tfrom, unroll env tto with
+ | (TInt _ | TEnum _),(TPtr _) -> true
+ | _,_ -> false
+
(* Construct an integer constant *)
let intconst v ik =
@@ -1007,10 +1019,6 @@ let sseq loc s1 s2 =
let sassign loc lv rv =
{ sdesc = Sdo (eassign lv rv); sloc = loc }
-(* Empty location *)
-
-let no_loc = ("", -1)
-
(* Dummy skip statement *)
let sskip = { sdesc = Sskip; sloc = no_loc }