From c3c0aba2ed285bc33208cfc67667f47d6d1b0762 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 23 Aug 2016 10:50:48 +0200 Subject: Fix for initialization of incomplete types Since some incomplete types are allowed in initialization just test whether the default initilization exists. Bug 19601 --- cparser/Cutil.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cparser/Cutil.ml') diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index 4b4e1b81..c8966941 100644 --- a/cparser/Cutil.ml +++ b/cparser/Cutil.ml @@ -1026,6 +1026,7 @@ let formatloc pp (filename, lineno) = if filename <> "" then Format.fprintf pp "%s:%d: " filename lineno (* Generate the default initializer for the given type *) +exception No_default_init let rec default_init env ty = match unroll env ty with @@ -1049,11 +1050,11 @@ let rec default_init env ty = | TUnion(id, _) -> let ci = Env.find_union env id in begin match ci.ci_members with - | [] -> assert false + | [] -> raise No_default_init | fld :: _ -> Init_union(id, fld, default_init env fld.fld_typ) end | _ -> - assert false + raise No_default_init (* Substitution of variables by expressions *) -- cgit