vala r991 - in trunk: . vala



Author: juergbi
Date: Thu Feb  7 17:36:38 2008
New Revision: 991
URL: http://svn.gnome.org/viewvc/vala?rev=991&view=rev

Log:
2008-02-07  Juerg Billeter  <j bitron ch>

	* vala/valasemanticanalyzer.vala: allow pointer arithmetic


Modified:
   trunk/ChangeLog
   trunk/vala/valasemanticanalyzer.vala

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Thu Feb  7 17:36:38 2008
@@ -2453,7 +2453,21 @@
 			   || 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]