diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2016-02-02 08:48:42 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2016-02-02 08:48:42 +0100 |
commit | 15fc340f69e9c4d718c15fd9ec12a81695cf8d67 (patch) | |
tree | 24e9472b03f5f6bdeee09f2984d7c23ea39d575a | |
parent | 774977824161f43104f1d31123a0e082395f0fe1 (diff) | |
download | compcert-15fc340f69e9c4d718c15fd9ec12a81695cf8d67.tar.gz compcert-15fc340f69e9c4d718c15fd9ec12a81695cf8d67.zip |
Make void always incomplete and exit on void members.
Since we cannot construct a default initializer for void types
we need to exit earlier.
Bug 18004.
-rw-r--r-- | cparser/Cutil.ml | 7 | ||||
-rw-r--r-- | cparser/Elab.ml | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/cparser/Cutil.ml b/cparser/Cutil.ml index 94e3e85d..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 *) diff --git a/cparser/Elab.ml b/cparser/Elab.ml index aed84a38..d7a1212a 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -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 *) |