aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cparser/Cutil.ml11
-rw-r--r--cparser/Elab.ml5
2 files changed, 11 insertions, 5 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml
index 1109cf79..c82ada26 100644
--- a/cparser/Cutil.ml
+++ b/cparser/Cutil.ml
@@ -552,7 +552,12 @@ let struct_layout env members =
(* Determine whether a type is incomplete *)
let incomplete_type env t =
- match sizeof env t with None -> true | Some _ -> false
+ match unroll env t with
+ | TVoid _ -> true (* Void is always incomplete *)
+ | _ -> begin match sizeof env t with
+ | None -> true
+ | Some _ -> false
+ end
(* Computing composite_info records *)
@@ -898,12 +903,12 @@ let is_debug_stmt s =
(* Assignment compatibility check over attributes.
Standard attributes ("const", "volatile", "restrict") can safely
be added (to the rhs type to get the lhs type) but must not be dropped.
- Custom attributes can safely be dropped but must not be added. *)
+ Custom attributes can safely be dropped or added. *)
let valid_assignment_attr afrom ato =
let (afromstd, afromcustom) = List.partition attr_is_standard afrom
and (atostd, atocustom) = List.partition attr_is_standard ato in
- incl_attributes afromstd atostd && incl_attributes atocustom afromcustom
+ incl_attributes afromstd atostd
(* Check that an assignment is allowed *)
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index d58d8be6..d7a1212a 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -131,7 +131,7 @@ let parse_int base s =
| _ -> assert false in
let v = ref 0L in
for i = 0 to String.length s - 1 do
- if !v > max_val then raise Overflow;
+ if !v < 0L || !v > max_val then raise Overflow;
v := Int64.mul !v (Int64.of_int base);
let c = s.[i] in
let digit =
@@ -706,7 +706,8 @@ and elab_struct_or_union_info kind loc env members attrs =
(* C99: ty[] allowed as last field of a struct *)
| fld :: rem ->
if wrap incomplete_type loc env' fld.fld_typ then
- error loc "member '%s' has incomplete type" fld.fld_name;
+ (* Must be fatal otherwise we get problems constructing the init *)
+ fatal_error loc "member '%s' has incomplete type" fld.fld_name;
check_incomplete rem in
check_incomplete m;
(* Warn for empty structs or unions *)