commit c32f54c6312385220fa2e721370647cf0b67607d
parent 271801416fc68607c87517c335a93f28319b41b8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 5 Nov 2021 21:43:14 +0100
cc2: Add array flag
When an array is loaded we have to do nothing, because an array
is loaded using only its address (like it was already donde for
aggregates).
Diffstat:
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/cmd/cc/cc2/cc2.h b/src/cmd/cc/cc2/cc2.h
@@ -12,6 +12,7 @@ enum tflags {
PARF = 1 << 6, /* parameter */
INITF = 1 << 7, /* initializer flag */
ELLIPS = 1 << 8, /* vararg function */
+ ARRF = 1 << 9, /* array flag */
};
enum sclass {
diff --git a/src/cmd/cc/cc2/parser.c b/src/cmd/cc/cc2/parser.c
@@ -571,6 +571,7 @@ array(void)
size = pop();
base = pop();
tp = pop();
+ tp->flags = ARRF;
tp->size = size->u.i * base->size; /* FIXME check for overflow */
tp->align = base->align;
diff --git a/src/cmd/cc/cc2/target/qbe/cgen.c b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -102,7 +102,7 @@ load(Type *tp, Node *np)
Node *new;
int flags = tp->flags;
- if (flags & (AGGRF|FUNF))
+ if (flags & (AGGRF|FUNF|ARRF))
return np;
switch (tp->size) {