From 21156a2fcf48764762c7f2209fa850024378d83a Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Fri, 29 Jul 2016 09:15:36 +0200 Subject: 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 --- cparser/Cutil.ml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'cparser/Cutil.ml') 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 } -- cgit