2008-02-07 Jürg Billeter <j@bitron.ch>
+ * vala/valasemanticanalyzer.vala: allow pointer arithmetic
+
+2008-02-07 Jürg Billeter <j@bitron.ch>
+
* vapi/packages/gtk+-2.0/gtk+-2.0.metadata: fix
gtk_tree_model_iter_nth_child binding, fixes bug 514869
|| expr.operator == BinaryOperator.MINUS
|| expr.operator == BinaryOperator.MUL
|| expr.operator == BinaryOperator.DIV) {
- expr.static_type = get_arithmetic_result_type (expr.left.static_type, expr.right.static_type);
+ // check for pointer arithmetic
+ if (expr.left.static_type is PointerType) {
+ var offset_type = expr.right.static_type.data_type as Struct;
+ if (offset_type != null && offset_type.is_integer_type ()) {
+ if (expr.operator == BinaryOperator.PLUS
+ || expr.operator == BinaryOperator.MINUS) {
+ // pointer arithmetic
+ expr.static_type = expr.left.static_type.copy ();
+ }
+ }
+ }
+
+ if (expr.static_type == null) {
+ expr.static_type = get_arithmetic_result_type (expr.left.static_type, expr.right.static_type);
+ }
if (expr.static_type == null) {
expr.error = true;