diff --git a/src/check.ml b/src/check.ml index d8ff57f4f..e7480baa0 100644 --- a/src/check.ml +++ b/src/check.ml @@ -583,9 +583,9 @@ and checkExp (isconst: bool) (e: exp) : typ = | AddrOfLabel (gref) -> begin (* Find a label *) let lab = - match List.filter (function Label _ -> true | _ -> false) + match List.find_opt (function Label _ -> true | _ -> false) !gref.labels with - Label (lab, _, _) :: _ -> lab + Some (Label (lab, _, _)) -> lab | _ -> ignore (warn "Address of label to block without a label"); "" @@ -748,9 +748,9 @@ and checkStmt (s: stmt) = currentLoc := l; (* Find a label *) let lab = - match List.filter (function Label _ -> true | _ -> false) + match List.find_opt (function Label _ -> true | _ -> false) !gref.labels with - Label (lab, _, _) :: _ -> lab + Some (Label (lab, _, _)) -> lab | _ -> ignore (warn "Goto to block without a label"); "" diff --git a/src/frontc/cabs2cil.ml b/src/frontc/cabs2cil.ml index b4366dbb6..66716e2ff 100644 --- a/src/frontc/cabs2cil.ml +++ b/src/frontc/cabs2cil.ml @@ -5637,10 +5637,9 @@ and doInit (* We have a designator *) | _, (what, ie) :: restil when what != A.NEXT_INIT -> let rec unrollDesignatorForNestedAnonymous (comp: compinfo) (designator: string) (whatnext: initwhat) = - let own_field = List.filter (fun fld -> fld.fname = designator) comp.cfields in - match own_field with - | fld :: _ -> (true, Some(A.INFIELD_INIT (designator, whatnext))) - | [] -> + if List.exists (fun fld -> fld.fname = designator) comp.cfields then + (true, Some(A.INFIELD_INIT (designator, whatnext))) + else let anonymous_compounds = List.filter_map (fun f -> (* f.ftype need not be unrolled here, inner anonymous struct cannot be typdef'ed *) match f.ftype with