ref: a5becc37677b6c86a026ce0ef9819e821d2d046a
parent: 4dca54568291a99779209f6b381435a6a62a232d
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Aug 14 11:37:16 EDT 2015
Fix emit field There were several errors in TEST002: , 2,$c The field operator was not emited, so TEST002 was failing.
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -9,7 +9,7 @@
static void emitbin(unsigned, void *),
emitcast(unsigned, void *), emitswitch(unsigned, void *),
- emitsym(unsigned, void *), emitfield(unsigned, void *),
+ emitsym(unsigned, void *),
emitexp(unsigned, void *),
emitsymid(unsigned, void *), emittext(unsigned, void *),
emitfun(unsigned, void *),
@@ -62,7 +62,8 @@
[OELOOP] = "\tb",
[OBLOOP] = "\td",
[OPAR] = "p",
- [OCALL] = "c"
+ [OCALL] = "c",
+ [OFIELD] = "."
};
void (*opcode[])(unsigned, void *) = {
@@ -106,7 +107,7 @@
[OSYM] = emitsym,
[OASK] = emitbin,
[OCOLON] = emitbin,
- [OFIELD]= emitfield,
+ [OFIELD]= emitbin,
[OEXPR] = emitexp,
[OLABEL] = emitsymid,
[ODEFAULT] = emitsymid,
@@ -366,16 +367,6 @@
Caselist *lcase = arg;
printf("\teI\t#%0x", lcase->nr);
-}
-
-void
-emitfield(unsigned op, void *arg)
-{
- Node *np = arg;
-
- emitnode(np->left);
- putchar('\t');
- emitvar(np->sym);
}
Node *
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -590,9 +590,8 @@
if ((sym = yylval.sym) == NULL)
error("incorrect field in struct/union");
next();
- np = node(OFIELD, sym->type, np, NULL);
+ np = node(OFIELD, sym->type, np, varnode(sym));
np->lvalue = 1;
- np->sym = sym;
return np;
default:
error("struct or union expected");
--- a/cc1/tests/test002.c
+++ b/cc1/tests/test002.c
@@ -2,7 +2,6 @@
name: TEST002
description: Test forward references before definition of types
output:
-S2 S
G4 P x
F1
X6 F1 main
@@ -9,11 +8,11 @@
G6 F1 main {
-
S2 S (
-M5 I
+M5 I i
)
A2 S2 y
A2 M5 .I #I0 :I
- G4 @S2 A2 :S
+ G4 @S2 A2 :S2
}
*/