summaryrefslogtreecommitdiff
path: root/usr.bin/pcc/ccom
diff options
context:
space:
mode:
authorAnders Magnusson <ragge@cvs.openbsd.org>2007-12-09 18:49:07 +0000
committerAnders Magnusson <ragge@cvs.openbsd.org>2007-12-09 18:49:07 +0000
commitaa8f37cfb2c1fe0b11d72ed67618dec1124a4f54 (patch)
tree184c13f2366d04218ca281459ac9ca93e5217759 /usr.bin/pcc/ccom
parent141ed79e7b891bd8643f6883644a07efa7b87ff4 (diff)
Updates from matser repo:
- Leave to target code to decide whether a node can be used for initialization or not. - Fix bug causing rw data to sometimes end up in ro segment.
Diffstat (limited to 'usr.bin/pcc/ccom')
-rw-r--r--usr.bin/pcc/ccom/init.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/usr.bin/pcc/ccom/init.c b/usr.bin/pcc/ccom/init.c
index e396cb9e645..6b2ff1e96f1 100644
--- a/usr.bin/pcc/ccom/init.c
+++ b/usr.bin/pcc/ccom/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.3 2007/11/16 09:00:12 otto Exp $ */
+/* $OpenBSD: init.c,v 1.4 2007/12/09 18:49:06 ragge Exp $ */
/*
* Copyright (c) 2004, 2007 Anders Magnusson (ragge@ludd.ltu.se).
@@ -453,7 +453,12 @@ nsetval(CONSZ off, int fsz, NODE *p)
static void
setscl(struct symtab *sp)
{
- setloc1((sp->squal << TSHIFT) & CON ? RDATA : DATA);
+ int ro = DATA;
+
+ if (BTYPE(sp->stype) == sp->stype && sp->squal == (CON >> TSHIFT))
+ ro = RDATA;
+ /* XXX - readonly pointers */
+ setloc1(ro);
defalign(talign(sp->stype, sp->ssue));
if (sp->sclass == EXTDEF ||
(sp->sclass == STATIC && sp->slevel == 0)) {
@@ -490,9 +495,11 @@ scalinit(NODE *p)
p = optim(p);
+#ifdef notdef /* leave to the target to decide if useable */
if (csym->sclass != AUTO && p->n_op != ICON &&
p->n_op != FCON && p->n_op != NAME)
cerror("scalinit not leaf");
+#endif
/* Out of elements? */
if (pstk == NULL) {
@@ -673,7 +680,7 @@ endinit(void)
infld(il->off, fsz, il->n->n_lval);
} else
ninval(il->off, fsz, il->n);
- nfree(il->n);
+ tfree(il->n);
}
lastoff = ll->begsz + il->off + fsz;
}
@@ -833,7 +840,7 @@ strcvt(NODE *p)
i = (unsigned char)s[-1];
asginit(bcon(i));
}
- nfree(p);
+ tfree(p);
}
/*
@@ -946,10 +953,7 @@ simpleinit(struct symtab *sp, NODE *p)
spname = sp;
p = optim(buildtree(ASSIGN, buildtree(NAME, NIL, NIL), p));
setscl(sp);
- if (p->n_right->n_op != ICON && p->n_right->n_op != FCON)
- uerror("initializer element is not a constant");
- else
- ninval(0, p->n_right->n_sue->suesize, p->n_right);
+ ninval(0, p->n_right->n_sue->suesize, p->n_right);
tfree(p);
break;