scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 7369e862b993e9e62b153f0101d0866f85d5a485
parent 565ba0922428a7a04198f8d11216309f018d6d50
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  5 Aug 2014 18:07:31 +0200

Decay expressions in assignop()

assignop() is called in any of the operator where an lvalue is
modified (=, *=, += ...). In this case is necessary decay the
right part of the expression, because in other case we will
generate code of assignment of arrays and functions.

Diffstat:
cc1/expr.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -329,8 +329,14 @@ iszero(Node *np) static Node * assignop(char op, Node *np1, Node *np2) { - if ((np2 = convert(np2, np1->type, 0)) == NULL) - error("incompatible types when assigning"); + switch (np2->type->op) { + case FTN: case ARY: + np2 = decay(np2); + /* PASSTHROUGH */ + default: + if ((np2 = convert(np2, np1->type, 0)) == NULL) + error("incompatible types when assigning"); + } return bincode(op, np1->type, np1, np2); }