commit 222655d71caa72a961f0a1573b42f48a891c5808
parent f1182f58c64e86472355891de7a035d984032d06
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 10 Aug 2014 23:03:19 +0200
Use type size in increments of pointers in cc1
The code was using always a value of 1, even in the case of
pointers, where the correct value is the size of the pointer.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -340,6 +340,7 @@ static Node *
incdec(Node *np, char op)
{
Type *tp = np->type;
+ Node *inc;
chklvalue(np, np->type);
@@ -347,11 +348,15 @@ incdec(Node *np, char op)
case PTR:
if (!tp->defined)
error("invalid use of indefined type");
+ inc = sizeofcode(tp->type);
+ break;
case INT: case FLOAT:
- return arithmetic(op, np, symcode(one));
+ inc = symcode(one);
+ break;
default:
error("incorrect type in arithmetic operation");
}
+ return arithmetic(op, np, inc);
}
static Node *