aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2017-02-16 15:53:06 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2017-02-16 15:53:06 +0100
commit9b63d90b40974eed35bd199fcfc6ccbabb1ed5b7 (patch)
treec5937772c4a783fae8f0306b62dec1a6a5f39ec1
parent380ef884523013fd02fe1c52b05d3b2a5b0b8818 (diff)
downloadcompcert-9b63d90b40974eed35bd199fcfc6ccbabb1ed5b7.tar.gz
compcert-9b63d90b40974eed35bd199fcfc6ccbabb1ed5b7.zip
Reverted changes in Cutil and catch in Cflow.
Instead of changing the definition of sizeof we now ignore errors raise in the Cflow module. Bug 21005
-rw-r--r--cparser/Cflow.ml1
-rw-r--r--cparser/Cutil.ml21
2 files changed, 5 insertions, 17 deletions
diff --git a/cparser/Cflow.ml b/cparser/Cflow.ml
index f5408c15..790d9079 100644
--- a/cparser/Cflow.ml
+++ b/cparser/Cflow.ml
@@ -117,6 +117,7 @@ let resolve_test env e =
match Ceval.integer_expr env e with
| None -> None
| Some n -> Some (n <> 0L)
+ | exception Env.Error _ -> None (* Any error due to local types should be ignored *)
let if_ env e (s1: flow) (s2: flow) : flow =
match resolve_test env e with
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index 903fd34c..6cafaf17 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -435,13 +435,6 @@ let alignof_fkind = function
let enum_ikind = IInt
-let wrap_alignof f env name =
- try
- let ci = f env name in
- ci.ci_alignof
- with Env.Error _ -> None
-
-
let rec alignof env t =
let a = alignas_attribute (attributes_of_type env t) in
if a > 0 then Some a else
@@ -454,9 +447,9 @@ let rec alignof env t =
| TFun(_, _, _, _) -> !config.alignof_fun
| TNamed(_, _) -> alignof env (unroll env t)
| TStruct(name, _) ->
- wrap_alignof Env.find_struct env name
+ let ci = Env.find_struct env name in ci.ci_alignof
| TUnion(name, _) ->
- wrap_alignof Env.find_union env name
+ let ci = Env.find_union env name in ci.ci_alignof
| TEnum(_, _) -> Some(alignof_ikind enum_ikind)
(* Compute the natural alignment of a struct or union. *)
@@ -501,12 +494,6 @@ let cautious_mul (a: int64) (b: int) =
then Some(Int64.to_int a * b)
else None
-let wrap_sizeof f env name =
- try
- let ci = f env name in
- ci.ci_sizeof
- with Env.Error _ -> None
-
(* Return size of type, in bytes, or [None] if the type is incomplete *)
let rec sizeof env t =
@@ -527,9 +514,9 @@ let rec sizeof env t =
| TFun(_, _, _, _) -> !config.sizeof_fun
| TNamed(_, _) -> sizeof env (unroll env t)
| TStruct(name, _) ->
- wrap_sizeof Env.find_struct env name
+ let ci = Env.find_struct env name in ci.ci_sizeof
| TUnion(name, _) ->
- wrap_sizeof Env.find_union env name
+ let ci = Env.find_union env name in ci.ci_sizeof
| TEnum(_, _) -> Some(sizeof_ikind enum_ikind)
(* Compute the size of a union.