aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Elab.ml
diff options
context:
space:
mode:
authorMichael Schmidt <github@mschmidt.me>2016-04-05 13:44:54 +0200
committerMichael Schmidt <github@mschmidt.me>2016-04-05 13:44:54 +0200
commit5c88ca36f5225231cc595fe0352c50a9e9fe83a2 (patch)
tree3c3075bebf8c5ffc9592fcd77467b36a448118cf /cparser/Elab.ml
parent1a02cbf4746bcbd059c35613d4a71cd127fbfa13 (diff)
downloadcompcert-5c88ca36f5225231cc595fe0352c50a9e9fe83a2.tar.gz
compcert-5c88ca36f5225231cc595fe0352c50a9e9fe83a2.zip
Catch initialization of arrays with single expressions, bug 18000
Diffstat (limited to 'cparser/Elab.ml')
-rw-r--r--cparser/Elab.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index e73b2f97..248b26f9 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -1150,6 +1150,14 @@ and elab_item zi item il =
let ini' = elab_list (I.top env (I.name zi) ty) il' true in
(* Initialize current subobject with this state, and continue *)
elab_list (I.set zi ini') il false
+ (* Single expression to initialize an array *)
+ | SINGLE_INIT a, TArray(ty_elt, sz, _) ->
+ let m = match unroll env ty_elt with
+ | TInt(t, _) when sizeof_ikind t = 1 -> " or string literal"
+ | TInt(t, _) when sizeof_ikind t = !config.sizeof_wchar -> " or wide string literal"
+ | _ -> "" in
+ error loc "array initializer must be an initializer list%s" m;
+ elab_list zi il false
(* Single expression *)
| SINGLE_INIT a, _ ->
let a' = !elab_expr_f loc env a in