[vala] Report error when using pointer arithmetic with void*



commit 14235edbf8e66d5d1d130c3e02ef9067e64635c2
Author: Jürg Billeter <j bitron ch>
Date:   Mon Sep 20 20:04:32 2010 +0200

    Report error when using pointer arithmetic with void*

 vala/valabinaryexpression.vala |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index ccbdf07..63a0c73 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -316,6 +316,13 @@ public class Vala.BinaryExpression : Expression {
 			   || operator == BinaryOperator.DIV) {
 			// check for pointer arithmetic
 			if (left.value_type is PointerType) {
+				var pointer_type = (PointerType) left.value_type;
+				if (pointer_type.base_type is VoidType) {
+					error = true;
+					Report.error (source_reference, "Pointer arithmetic not supported for `void*'");
+					return false;
+				}
+
 				var offset_type = right.value_type.data_type as Struct;
 				if (offset_type != null && offset_type.is_integer_type ()) {
 					if (operator == BinaryOperator.PLUS



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