ref: 4faaf322b43040ad88b52e4917e753a64ea82b94
parent: 0f2cb2792bc4b51ec4bd7ea4d90a6e572bd78860
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue May 12 06:37:41 EDT 2015
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.
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -108,7 +108,12 @@
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);
}
/*