From 7163353c9612dd4955b76ddf3ff96c6eb7c597a8 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Thu, 7 Feb 2008 17:36:38 +0000 Subject: [PATCH] allow pointer arithmetic 2008-02-07 Juerg Billeter * vala/valasemanticanalyzer.vala: allow pointer arithmetic svn path=/trunk/; revision=991 --- ChangeLog | 4 ++++ vala/valasemanticanalyzer.vala | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fda8edb..d3f9268 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-02-07 Jürg Billeter + * vala/valasemanticanalyzer.vala: allow pointer arithmetic + +2008-02-07 Jürg Billeter + * vapi/packages/gtk+-2.0/gtk+-2.0.metadata: fix gtk_tree_model_iter_nth_child binding, fixes bug 514869 diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index b386ad9..89b21e0 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -2453,7 +2453,21 @@ public class Vala.SemanticAnalyzer : CodeVisitor { || 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; -- 2.7.4