]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Report error when using pointer arithmetic with void*
authorJürg Billeter <j@bitron.ch>
Mon, 20 Sep 2010 18:04:32 +0000 (20:04 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 20 Sep 2010 18:04:32 +0000 (20:04 +0200)
vala/valabinaryexpression.vala

index ccbdf07d6bf632f2cbb5135c19b7b98824e5abb6..63a0c732b799984be7a1a126bb1edf6379482695 100644 (file)
@@ -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