Browse Source

skip over unsafe casts when making constant expressions, but add them back afterwards

Simon Krajewski 12 years ago
parent
commit
8e28dcb8d1
1 changed files with 4 additions and 0 deletions
  1. 4 0
      optimizer.ml

+ 4 - 0
optimizer.ml

@@ -959,6 +959,10 @@ let rec make_constant_expression ctx ?(concat_strings=false) e =
 			Some (mk (TConst (TString (s1 ^ s2))) ctx.com.basic.tstring (punion e1.epos e2.epos))
 		| Some e1, Some e2 -> Some (mk (TBinop(op, e1, e2)) e.etype e.epos)
 		| _ -> None)
+	| TCast (e1, None) ->
+		(match make_constant_expression ctx e1 with
+		| None -> None
+		| Some e1 -> Some {e with eexpr = TCast(e1,None)})
 	| TParenthesis e | TMeta(_,e) -> Some e
 	| TTypeExpr _ -> Some e
 	(* try to inline static function calls *)