From 5c88ca36f5225231cc595fe0352c50a9e9fe83a2 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Tue, 5 Apr 2016 13:44:54 +0200 Subject: Catch initialization of arrays with single expressions, bug 18000 --- cparser/Elab.ml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cparser/Elab.ml') 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 -- cgit