[hackers] [scc] Fix emit field || Roberto E. Vargas Caballero
commit a5becc37677b6c86a026ce0ef9819e821d2d046a
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Aug 14 15:37:16 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Aug 14 15:37:16 2015 +0200
Fix emit field
There were several errors in TEST002:
,
2,$c
The field operator was not emited, so TEST002 was failing.
diff --git a/cc1/code.c b/cc1/code.c
index 8b324af..bb2f9d0 100644
--- a/cc1/code.c
+++ b/cc1/code.c
_AT_@ -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 *),
_AT_@ -62,7 +62,8 @@ char *optxt[] = {
[OELOOP] = "\tb",
[OBLOOP] = "\td",
[OPAR] = "p",
- [OCALL] = "c"
+ [OCALL] = "c",
+ [OFIELD] = "."
};
void (*opcode[])(unsigned, void *) = {
_AT_@ -106,7 +107,7 @@ void (*opcode[])(unsigned, void *) = {
[OSYM] = emitsym,
[OASK] = emitbin,
[OCOLON] = emitbin,
- [OFIELD]= emitfield,
+ [OFIELD]= emitbin,
[OEXPR] = emitexp,
[OLABEL] = emitsymid,
[ODEFAULT] = emitsymid,
_AT_@ -368,16 +369,6 @@ emitswitch(unsigned op, void *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 *
node(unsigned op, Type *tp, Node *lp, Node *rp)
{
diff --git a/cc1/expr.c b/cc1/expr.c
index c4890ef..35a4394 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -590,9 +590,8 @@ field(Node *np)
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");
diff --git a/cc1/tests/test002.c b/cc1/tests/test002.c
index a19430d..e739445 100644
--- a/cc1/tests/test002.c
+++ b/cc1/tests/test002.c
_AT_@ -2,18 +2,17 @@
name: TEST002
description: Test forward references before definition of types
output:
-S2 S
G4 P x
F1
X6 F1 main
G6 F1 main {
-
S2 S (
-M5 I
+M5 I i
)
A2 S2 y
A2 M5 .I #I0 :I
- G4 _AT_S2 A2 :S
+ G4 _AT_S2 A2 :S2
}
*/
Received on Fri Aug 14 2015 - 17:08:59 CEST
This archive was generated by hypermail 2.3.0
: Fri Aug 14 2015 - 17:12:23 CEST