*)
+(*
+ * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
+ * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
+ * This file is part of Coccinelle.
+ *
+ * Coccinelle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, according to version 2 of the License.
+ *
+ * Coccinelle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The authors reserve the right to distribute this or future versions of
+ * Coccinelle under other licenses.
+ *)
+
+
module T = Type_cocci
module Ast = Ast_cocci
module Ast0 = Ast0_cocci
Ast0.set_type exp1 ty; Ast0.set_type exp2 ty; ty in
(match Ast0.unwrap_mcode op with
Ast.Arith(op) -> same_type (ty1, ty2)
+ | Ast.Logical(Ast.AndLog) | Ast.Logical(Ast.OrLog) ->
+ Some(bool_type)
| Ast.Logical(op) ->
let ty = lub_type ty1 ty2 in
- Ast0.set_type exp1 ty; Ast0.set_type exp2 ty;
- Some(bool_type))
+ Ast0.set_type exp1 ty; Ast0.set_type exp2 ty;
+ Some(bool_type))
| Ast0.Paren(lp,exp,rp) -> Ast0.get_type exp
| Ast0.ArrayAccess(exp1,lb,exp2,rb) ->
(match strip_cv (Ast0.get_type exp2) with
None -> Ast0.set_type exp2 (Some(int_type))
| Some(ty) when is_int_type ty -> ()
+ | Some(Type_cocci.Unknown) ->
+ (* unknown comes from param types, not sure why this
+ is not just None... *)
+ Ast0.set_type exp2 (Some(int_type))
| Some ty -> err exp2 ty "bad type for an array index");
(match strip_cv (Ast0.get_type exp1) with
None -> None