commit 3264efeca8c41b909a8fca2c57785f936fb55f80
parent c946d13235a8460a8c7f2aa86e705202d77231a7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 18 Jun 2022 06:35:40 +0200
cc1: Add debug information about decay
Applying decay can heavily modify the behaviour of some expressions.
Diffstat:
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/cmd/cc/cc1/code.c b/src/cmd/cc/cc1/code.c
@@ -578,5 +578,6 @@ sizeofnode(Type *tp)
sym = newsym(NS_IDEN, NULL);
sym->type = sizettype;
sym->u.i = tp->size;
+ DBG("EXPR sizeof %llu", sym->u.i);
return constnode(sym);
}
diff --git a/src/cmd/cc/cc1/expr.c b/src/cmd/cc/cc1/expr.c
@@ -194,6 +194,7 @@ decay(Node *np)
switch (tp->op) {
case ARY:
+ DBG("EXPR decay ary");
tp = tp->type;
if (np->op == OPTR) {
new = np->left;
@@ -201,14 +202,18 @@ decay(Node *np)
new->type = mktype(tp, PTR, 0, NULL);
return new;
}
+ break;
case FTN:
- new = node(OADDR, mktype(tp, PTR, 0, NULL), np, NULL);
- if (np->sym && np->sym->flags & (SGLOBAL|SLOCAL|SPRIVATE))
- new->flags |= NCONST;
- return new;
+ DBG("EXPR decay function");
+ break;
default:
return np;
}
+
+ new = node(OADDR, mktype(tp, PTR, 0, NULL), np, NULL);
+ if (np->sym && np->sym->flags & (SGLOBAL|SLOCAL|SPRIVATE))
+ new->flags |= NCONST;
+ return new;
}
static Node *