ref: 7369e862b993e9e62b153f0101d0866f85d5a485
parent: 565ba0922428a7a04198f8d11216309f018d6d50
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Aug 5 14:07:31 EDT 2014
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.
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -329,8 +329,14 @@
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);
}