aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Elab.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bschommer@users.noreply.github.com>2018-03-27 17:15:42 +0200
committerGitHub <noreply@github.com>2018-03-27 17:15:42 +0200
commitfbc778079d50a4af45b9a648eab56cef29ac75f4 (patch)
tree8131a5099e363d68dc3a565e83ed72485138606f /cparser/Elab.ml
parent2b79fd958026b3a9bcdd2452b1a4c217a084de92 (diff)
downloadcompcert-fbc778079d50a4af45b9a648eab56cef29ac75f4.tar.gz
compcert-fbc778079d50a4af45b9a648eab56cef29ac75f4.zip
Sizeof and _Alignof are not allowed on bit-fields (#67)
Sizeof and _Alignof are not allowed on bit-fields Sizeof and _Alignof are not allowed to be applied to a expression that designates a bit-field member. Bug 23311
Diffstat (limited to 'cparser/Elab.ml')
-rw-r--r--cparser/Elab.ml6
1 files changed, 5 insertions, 1 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 3ef489c1..204bc515 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1619,6 +1619,8 @@ let elab_expr vararg loc env a =
let b1,env = elab env a1 in
if wrap incomplete_type loc env b1.etyp then
error "invalid application of 'sizeof' to an incomplete type %a" (print_typ env) b1.etyp;
+ if wrap is_bitfield loc env b1 then
+ error "invalid application of 'sizeof' to a bit-field";
let bdesc =
(* Catch special cases sizeof("string literal") *)
match b1.edesc with
@@ -1641,7 +1643,9 @@ let elab_expr vararg loc env a =
| EXPR_ALIGNOF a1 ->
let b1,env = elab env a1 in
if wrap incomplete_type loc env b1.etyp then
- error "invalid application of 'alignof' to an incomplete type %a" (print_typ env) b1.etyp;
+ error "invalid application of '_Alignof' to an incomplete type %a" (print_typ env) b1.etyp;
+ if wrap is_bitfield loc env b1 then
+ error "invalid application of '_Alignof' to a bit-field";
{ edesc = EAlignof b1.etyp; etyp = TInt(size_t_ikind(), []) },env
| TYPE_ALIGNOF (spec, dcl) ->