summaryrefslogtreecommitdiff
path: root/cparser/Elab.ml
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-09 12:25:03 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-09 12:25:03 +0000
commitd966e01ea011fa66d5a5a7f9ffce4344e415981a (patch)
tree487a86c759777b54a9e9dda72c602348c9270920 /cparser/Elab.ml
parentb66aaf2d1b90ff51f54bcd2a344a6ab50ac6fe86 (diff)
Bug fix: infinite loop in cparser/ on bit field of size 32 bits.
Algorithmic efficiency: in cparser/, precompute sizeof and alignof of composites. Code cleanup: introduced Cutil.composite_info_{def,decl} git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1312 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cparser/Elab.ml')
-rw-r--r--cparser/Elab.ml11
1 files changed, 5 insertions, 6 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 5971d4d..7204508 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -565,8 +565,7 @@ and elab_struct_or_union_info kind loc env members =
error loc "member '%s' has incomplete type" fld.fld_name;
check_incomplete rem in
check_incomplete m;
- ({ ci_kind = kind; ci_incomplete = false; ci_members = m },
- env')
+ (composite_info_def env' kind m, env')
(* Elaboration of a struct or union *)
@@ -582,7 +581,7 @@ and elab_struct_or_union only kind loc tag optmembers env =
create a new incomplete composite instead via the case
"_, None" below. *)
(tag', env)
- | Some(tag', ({ci_incomplete = true} as ci)), Some members
+ | Some(tag', ({ci_sizeof = None} as ci)), Some members
when Env.in_current_scope env tag' ->
if ci.ci_kind <> kind then
error loc "struct/union mismatch on tag '%s'" tag;
@@ -593,7 +592,7 @@ and elab_struct_or_union only kind loc tag optmembers env =
(Gcompositedef(kind, tag', ci'.ci_members));
(* Replace infos but keep same ident *)
(tag', Env.add_composite env' tag' ci')
- | Some(tag', {ci_incomplete = false}), Some _
+ | Some(tag', {ci_sizeof = Some _}), Some _
when Env.in_current_scope env tag' ->
error loc "redefinition of struct or union '%s'" tag;
(tag', env)
@@ -601,7 +600,7 @@ and elab_struct_or_union only kind loc tag optmembers env =
(* declaration of an incomplete struct or union *)
if tag = "" then
error loc "anonymous, incomplete struct or union";
- let ci = { ci_kind = kind; ci_incomplete = true; ci_members = [] } in
+ let ci = composite_info_decl env kind in
(* enter it with a new name *)
let (tag', env') = Env.enter_composite env tag ci in
(* emit it *)
@@ -610,7 +609,7 @@ and elab_struct_or_union only kind loc tag optmembers env =
(tag', env')
| _, Some members ->
(* definition of a complete struct or union *)
- let ci1 = { ci_kind = kind; ci_incomplete = true; ci_members = [] } in
+ let ci1 = composite_info_decl env kind in
(* enter it, incomplete, with a new name *)
let (tag', env') = Env.enter_composite env tag ci1 in
(* emit a declaration so that inner structs and unions can refer to it *)