commit 4faaf322b43040ad88b52e4917e753a64ea82b94
parent 0f2cb2792bc4b51ec4bd7ea4d90a6e572bd78860
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 12 May 2015 10:37:41 +0200
Fix decay()
Decay does different things in the case of an array, and in the case
of a function. In the first case it generates a pointer to the first
element of the array, and in the second case it generates a pointer
to the function.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -108,7 +108,12 @@ integeruop(char op, Node *np)
static Node *
decay(Node *np)
{
- return node(OADDR, mktype(np->type, PTR, 0, NULL), np, NULL);
+ Type *tp = tp->type;
+
+ if (tp->op == ARY)
+ tp = tp->type;
+
+ return node(OADDR, mktype(tp, PTR, 0, NULL), np, NULL);
}
/*