@@ -543,6 +543,9 @@ let docEnv () =
543543 H. iter (fun k d -> acc := (k, d) :: ! acc) env;
544544 docList ~sep: line (fun (k , d ) -> dprintf " %s -> %a" k doone d) () ! acc
545545
546+ let rec stripParenLocal e = match e with
547+ | A. PAREN e2 -> stripParenLocal e2
548+ | _ -> e
546549
547550
548551(* Add a new variable. Do alpha-conversion if necessary *)
@@ -666,6 +669,7 @@ let rec stripConstLocalType (t: typ) : typ =
666669 let a' = dc a in if a != a' then TVoid a' else t
667670 | TBuiltin_va_list a ->
668671 let a' = dc a in if a != a' then TBuiltin_va_list a' else t
672+ | TDefault -> t
669673
670674
671675let constFoldTypeVisitor = object (self )
@@ -4847,24 +4851,29 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
48474851 | A. EXPR_PATTERN _ -> E. s (E. bug " EXPR_PATTERN in cabs2cil input" )
48484852
48494853 | A. GENERIC (expr , lst ) ->
4850- let get_exp tupel = match tupel with _ , e , _ -> e in
4851- let exp = get_exp (doExp false expr (AExp None )) in
4852- let rec make_cil_list cabs_l cil_l = match cabs_l with
4854+ let get_exp (_ , e , _ ) = e in
4855+ let exp = get_exp (doExp false (stripParenLocal expr) (AExp None )) in
4856+ let cil_list =
4857+ let rec make_cil_list cabs_l cil_l = match cabs_l with
48534858 | [] -> cil_l
4854- | (s , e ) :: rest -> make_cil_list rest (((doOnlyType s JUSTBASE ),get_exp (doExp false e (AExp None ))) :: cil_l)
4859+ | (s , e ) :: rest -> make_cil_list rest (((doOnlyType s JUSTBASE ),get_exp (doExp false (stripParenLocal e) (AExp None ))) :: cil_l)
4860+ in
4861+ make_cil_list lst []
48554862 in
4856- let cil_list = make_cil_list lst [] in
48574863 let exp_typ = typeOf exp in
48584864 let default_typ = ref voidType in
48594865 let typ =
4860- let rec get_typ l = match l with
4866+ let rec get_typ lst = match lst with
48614867 | (TDefault, e ) :: rest -> default_typ := typeOf e; get_typ rest
48624868 | (t , e ) :: rest -> if t = exp_typ then typeOf e else get_typ rest
4863- | [] -> ! default_typ
4869+ | [] ->
4870+ if ! default_typ = voidType then
4871+ E. s(error " Controlling expression of generic selection is not compatible with any association" )
4872+ else ! default_typ
48644873 in
48654874 get_typ cil_list
48664875 in
4867- finishExp empty (Generic (exp, (make_cil_list lst [] ))) typ
4876+ finishExp empty (Generic (exp, (cil_list ))) typ
48684877
48694878 with e when continueOnError -> begin
48704879 (* ignore (E.log "error in doExp (%s)" (Printexc.to_string e));*)
@@ -6833,11 +6842,6 @@ and doStatement (s : A.statement) : chunk =
68336842 consLabel " booo_statement" empty (convLoc (C. get_statementloc s)) false
68346843 end
68356844
6836-
6837- let rec stripParenLocal e = match e with
6838- | A. PAREN e2 -> stripParenLocal e2
6839- | _ -> e
6840-
68416845class stripParenClass : V. cabsVisitor = object (self )
68426846 inherit V. nopCabsVisitor
68436847
0 commit comments