summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Magnusson <ragge@cvs.openbsd.org>2007-11-18 17:39:56 +0000
committerAnders Magnusson <ragge@cvs.openbsd.org>2007-11-18 17:39:56 +0000
commitffbcd0d1cc4b8a79cd425a475380a55dc3d1b6e8 (patch)
tree3f2710e8c7df5eef44042f03eaf7ecb0918a7553
parent0002b12aff4753fec661ccc9e71178e0039ede32 (diff)
(Large) update from master repo:
> Use structure assignment instead of calling memcpy directly in struct return. > Rewrite enum handling. > In C99 enums are treated like INTs so convert them early to int. > Move the enum tag handling out of defid(), tags are in their own namespace. > This will be done with struct/union tags also. > Comment out enum types. > Remove ENUMTY/MOETY from target code.
-rw-r--r--usr.bin/pcc/ccom/cgram.y21
-rw-r--r--usr.bin/pcc/ccom/optim.c4
-rw-r--r--usr.bin/pcc/ccom/pass1.h9
-rw-r--r--usr.bin/pcc/ccom/pftn.c212
-rw-r--r--usr.bin/pcc/ccom/trees.c88
-rw-r--r--usr.bin/pcc/hppa/local.c4
-rw-r--r--usr.bin/pcc/i386/code.c24
-rw-r--r--usr.bin/pcc/i386/local.c4
-rw-r--r--usr.bin/pcc/mip/manifest.h6
-rw-r--r--usr.bin/pcc/mip/match.c4
-rw-r--r--usr.bin/pcc/mips/local.c4
-rw-r--r--usr.bin/pcc/nova/local.c4
-rw-r--r--usr.bin/pcc/pdp10/local.c4
-rw-r--r--usr.bin/pcc/powerpc/local.c4
14 files changed, 167 insertions, 225 deletions
diff --git a/usr.bin/pcc/ccom/cgram.y b/usr.bin/pcc/ccom/cgram.y
index 543318a2d93..10961e47eae 100644
--- a/usr.bin/pcc/ccom/cgram.y
+++ b/usr.bin/pcc/ccom/cgram.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: cgram.y,v 1.4 2007/11/16 09:00:12 otto Exp $ */
+/* $OpenBSD: cgram.y,v 1.5 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
@@ -153,6 +153,7 @@ static int fun_inline; /* Reading an inline function */
int oldstyle; /* Current function being defined */
int noretype;
static struct symtab *xnf;
+extern int enummer;
#ifdef GCC_COMPAT
char *renname; /* for renaming of variables */
#endif
@@ -208,8 +209,8 @@ struct savbc {
identifier_list arg_param_list arg_declaration arg_dcl_list
designator_list designator
%type <strp> string wstring C_STRING C_WSTRING PRAG_RENAMED
-%type <rp> enum_head str_head
-%type <symp> xnfdeclarator clbrace
+%type <rp> str_head
+%type <symp> xnfdeclarator clbrace enum_head
%type <intval> C_CLASS C_STRUCT C_RELOP C_DIVOP C_SHIFTOP
C_ANDAND C_OROR C_STROP C_INCOP C_UNOP C_ASOP C_EQUOP
@@ -486,22 +487,20 @@ init_declarator_list:
| init_declarator_list ',' { $<nodep>$ = $<nodep>0; } init_declarator
;
-enum_dcl: enum_head '{' moe_list optcomma '}' { $$ = dclstruct($1, 0); }
- | C_ENUM C_NAME { $$ = rstruct($2,0); }
- | C_ENUM C_TYPENAME { $$ = rstruct($2,0); }
+enum_dcl: enum_head '{' moe_list optcomma '}' { $$ = enumdcl($1); }
+ | C_ENUM C_NAME { $$ = enumref($2); }
;
-enum_head: C_ENUM { $$ = bstruct(NULL,0); }
- | C_ENUM C_NAME { $$ = bstruct($2,0); }
- | C_ENUM C_TYPENAME { $$ = bstruct($2,0); }
+enum_head: C_ENUM { $$ = enumhd(NULL); }
+ | C_ENUM C_NAME { $$ = enumhd($2); }
;
moe_list: moe
| moe_list ',' moe
;
-moe: C_NAME { moedef( $1 ); }
- | C_NAME '=' con_e { strucoff = $3; moedef( $1 ); }
+moe: C_NAME { moedef($1); }
+ | C_NAME '=' con_e { enummer = $3; moedef($1); }
;
struct_dcl: str_head '{' struct_dcl_list '}' str_attr {
diff --git a/usr.bin/pcc/ccom/optim.c b/usr.bin/pcc/ccom/optim.c
index 3acef181c7f..e4b48144cd5 100644
--- a/usr.bin/pcc/ccom/optim.c
+++ b/usr.bin/pcc/ccom/optim.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: optim.c,v 1.1 2007/10/07 17:58:51 otto Exp $ */
+/* $OpenBSD: optim.c,v 1.2 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
*
@@ -92,7 +92,7 @@ optim(NODE *p)
int i;
TWORD t;
- if( (t=BTYPE(p->n_type))==ENUMTY || t==MOETY ) econvert(p);
+ t = BTYPE(p->n_type);
if( oflag ) return(p);
ty = coptype(p->n_op);
diff --git a/usr.bin/pcc/ccom/pass1.h b/usr.bin/pcc/ccom/pass1.h
index c6912271dcf..c736b681043 100644
--- a/usr.bin/pcc/ccom/pass1.h
+++ b/usr.bin/pcc/ccom/pass1.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1.h,v 1.3 2007/11/16 09:00:12 otto Exp $ */
+/* $OpenBSD: pass1.h,v 1.4 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
*
@@ -134,8 +134,8 @@ union arglist {
union dimfun *df;
struct suedef *sue;
};
-#define TNULL INCREF(MOETY) /* pointer to MOETY -- impossible type */
-#define TELLIPSIS INCREF(INCREF(MOETY))
+#define TNULL INCREF(FARG) /* pointer to FARG -- impossible type */
+#define TELLIPSIS INCREF(INCREF(FARG))
/*
* Symbol table definition.
@@ -321,6 +321,9 @@ void myp2tree(NODE *);
void lcommprint(void);
void lcommdel(struct symtab *);
NODE *funcode(NODE *);
+struct symtab *enumhd(char *);
+NODE *enumdcl(struct symtab *);
+NODE *enumref(char *);
#ifdef GCC_COMPAT
void gcc_init(void);
diff --git a/usr.bin/pcc/ccom/pftn.c b/usr.bin/pcc/ccom/pftn.c
index 21c59e71839..a602e7322d9 100644
--- a/usr.bin/pcc/ccom/pftn.c
+++ b/usr.bin/pcc/ccom/pftn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pftn.c,v 1.7 2007/11/16 09:00:12 otto Exp $ */
+/* $OpenBSD: pftn.c,v 1.8 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -89,7 +89,7 @@ int reached, prolab;
struct params;
-#define ISSTR(ty) (ty == STRTY || ty == UNIONTY || ty == ENUMTY)
+#define ISSTR(ty) (ty == STRTY || ty == UNIONTY)
#define ISSOU(ty) (ty == STRTY || ty == UNIONTY)
#define MKTY(p, t, d, s) r = talloc(); *r = *p; \
r = argcast(r, t, d, s); *p = *r; nfree(r);
@@ -204,8 +204,6 @@ defid(NODE *q, int class)
case STNAME:
case MOU:
case UNAME:
- case MOE:
- case ENAME:
case TYPEDEF:
;
}
@@ -254,9 +252,9 @@ defid(NODE *q, int class)
#endif
/* check that redeclarations are to the same structure */
- if ((temp == STRTY || temp == UNIONTY || temp == ENUMTY) &&
+ if ((temp == STRTY || temp == UNIONTY) &&
p->ssue != q->n_sue &&
- class != STNAME && class != UNAME && class != ENAME) {
+ class != STNAME && class != UNAME) {
goto mismatch;
}
@@ -334,9 +332,6 @@ defid(NODE *q, int class)
}
break;
- case MOE:
- break;
-
case EXTDEF:
switch (scl) {
case EXTERN:
@@ -350,7 +345,6 @@ defid(NODE *q, int class)
case STNAME:
case UNAME:
- case ENAME:
if (scl != class)
break;
if (p->ssue->suesize == 0)
@@ -390,22 +384,26 @@ defid(NODE *q, int class)
p->slevel = blevel;
p->soffset = NOOFFSET;
p->suse = lineno;
- if (class == STNAME || class == UNAME || class == ENAME) {
+ if (class == STNAME || class == UNAME) {
p->ssue = permalloc(sizeof(struct suedef));
suedefcnt++;
p->ssue->suesize = 0;
p->ssue->suelem = NULL;
p->ssue->suealign = ALSTRUCT;
} else {
+ if (q->n_sue == NULL)
+ cerror("q->n_sue == NULL");
+ p->ssue = q->n_sue;
+#if 0
switch (BTYPE(type)) {
case STRTY:
case UNIONTY:
- case ENUMTY:
p->ssue = q->n_sue;
break;
default:
p->ssue = MKSUE(BTYPE(type));
}
+#endif
}
/* copy dimensions */
@@ -464,12 +462,6 @@ defid(NODE *q, int class)
strucoff = 0;
ssave(p);
break;
-
- case MOE:
- p->soffset = strucoff++;
- ssave(p);
- break;
-
}
#ifdef STABS
@@ -656,9 +648,9 @@ rstruct(char *tag, int soru)
q = block(NAME, NIL, NIL, 0, 0, 0);
q->n_sp = p;
q->n_type = (soru&INSTRUCT) ? STRTY :
- ((soru&INUNION) ? UNIONTY : ENUMTY);
+ ((soru&INUNION) ? UNIONTY : 0);
defid(q, (soru&INSTRUCT) ? STNAME :
- ((soru&INUNION) ? UNAME : ENAME));
+ ((soru&INUNION) ? UNAME : 0));
nfree(q);
break;
@@ -672,26 +664,122 @@ rstruct(char *tag, int soru)
break;
goto def;
- case ENUMTY:
- if (!(soru&(INUNION|INSTRUCT)))
- break;
- goto def;
-
}
q = mkty(p->stype, 0, p->ssue);
q->n_sue = p->ssue;
return q;
}
+/*
+ * Declare a struct/union/enum tag.
+ * If not found, create a new tag with UNDEF type.
+ */
+static struct symtab *
+deftag(char *name, int class)
+{
+ struct symtab *sp;
+
+ sp = lookup(name, STAGNAME);
+ if (sp->ssue == NULL)
+ sp->ssue = permalloc(sizeof(struct suedef));
+ if (sp->sclass == SNULL) {
+ /* New tag */
+ sp->sclass = class;
+ } else if (sp->slevel < blevel) {
+ /* declared at different block level, hide it */
+ sp = hide(sp);
+ sp->sclass = class;
+ } else if (sp->sclass != class) {
+ /* redeclaration of tag */
+ uerror("tag %s redeclared", name);
+ }
+ return sp;
+}
+
+static int enumlow, enumhigh;
+int enummer;
+
+/*
+ * Declare a member of enum.
+ */
void
moedef(char *name)
{
- NODE *q;
+ struct symtab *sp;
- q = block(NAME, NIL, NIL, MOETY, 0, 0);
- q->n_sp = lookup(name, 0);
- defid(q, MOE);
- nfree(q);
+ sp = lookup(name, SNORMAL);
+ if (sp->stype == UNDEF || (sp->slevel < blevel)) {
+ if (sp->stype != UNDEF)
+ sp = hide(sp);
+ sp->stype = INT; /* always */
+ sp->ssue = MKSUE(INT);
+ sp->sclass = MOE;
+ sp->soffset = enummer;
+ } else
+ uerror("%s redeclared", name);
+ if (enummer < enumlow)
+ enumlow = enummer;
+ if (enummer > enumhigh)
+ enumhigh = enummer;
+ enummer++;
+}
+
+/*
+ * Declare an enum tag. Complain if already defined.
+ */
+struct symtab *
+enumhd(char *name)
+{
+ struct symtab *sp;
+
+ enummer = enumlow = enumhigh = 0;
+ if (name == NULL)
+ return NULL;
+
+ sp = deftag(name, ENAME);
+ if (sp->stype != UNDEF) /* enum type already declared */
+ uerror("%s redeclared", name);
+ return sp;
+}
+
+/*
+ * finish declaration of an enum
+ */
+NODE *
+enumdcl(struct symtab *sp)
+{
+ TWORD t;
+
+#ifdef ENUMSIZE
+ t = ENUMSIZE(enumhigh, enumlow);
+#else
+ if (enumhigh <= MAX_CHAR && enumlow >= MIN_CHAR)
+ t = ctype(CHAR);
+ else if (enumhigh <= MAX_SHORT && enumlow >= MIN_SHORT)
+ t = ctype(SHORT);
+ else
+ t = ctype(INT);
+#endif
+ if (sp) {
+ sp->stype = t;
+ sp->ssue = MKSUE(t);
+ }
+ return mkty(t, 0, MKSUE(t));
+}
+
+/*
+ * Handle reference to an enum
+ */
+NODE *
+enumref(char *name)
+{
+ struct symtab *sp;
+
+ sp = lookup(name, STAGNAME);
+ if (sp->sclass != ENAME)
+ uerror("enum %s undeclared", name);
+
+ return mkty(sp->stype, 0, sp->ssue);
}
/*
@@ -728,11 +816,8 @@ bstruct(char *name, int soru)
q->n_type = UNIONTY;
if (s != NULL)
defid(q, UNAME);
- } else { /* enum */
- strunem = MOE;
- q->n_type = ENUMTY;
- if (s != NULL)
- defid(q, ENAME);
+ } else {
+ cerror("bstruct");
}
r->rsym = q->n_sp;
r->rlparam = lparam;
@@ -767,7 +852,7 @@ dclstruct(struct rstack *r, int pa)
if (ddebug)
printf("dclstruct(%s)\n", r->rsym ? r->rsym->sname : "??");
#endif
- temp = (instruct&INSTRUCT)?STRTY:((instruct&INUNION)?UNIONTY:ENUMTY);
+ temp = (instruct&INSTRUCT)?STRTY:((instruct&INUNION)?UNIONTY:0);
instruct = r->rinstruct;
strunem = r->rclass;
al = ALSTRUCT;
@@ -793,14 +878,6 @@ dclstruct(struct rstack *r, int pa)
if (p == NULL)
cerror("gummy structure member");
- if (temp == ENUMTY) {
- if (p->soffset < low)
- low = p->soffset;
- if (p->soffset > high)
- high = p->soffset;
- p->ssue = sue;
- continue;
- }
sa = talign(p->stype, p->ssue);
if (p->sclass & FIELD)
sz = p->sclass&FLDSIZ;
@@ -827,23 +904,6 @@ dclstruct(struct rstack *r, int pa)
sue->suelem[i] = NULL;
SETOFF(strucoff, al);
- if (temp == ENUMTY) {
- TWORD ty;
-
-#ifdef ENUMSIZE
- ty = ENUMSIZE(high,low);
-#else
- if ((char)high == high && (char)low == low)
- ty = ctype(CHAR);
- else if ((short)high == high && (short)low == low)
- ty = ctype(SHORT);
- else
- ty = ctype(INT);
-#endif
- strucoff = tsize(ty, 0, MKSUE(ty));
- sue->suealign = al = talign(ty, MKSUE(ty));
- }
-
sue->suesize = strucoff;
sue->suealign = al;
@@ -1001,7 +1061,6 @@ talign(unsigned int ty, struct suedef *sue)
switch( BTYPE(ty) ){
case UNIONTY:
- case ENUMTY:
case STRTY:
return((unsigned int)sue->suealign);
case BOOL:
@@ -1366,14 +1425,6 @@ falloc(struct symtab *p, int w, int new, NODE *pty)
/* this must be fixed to use the current type in alignments */
switch( new<0?pty->n_type:p->stype ){
- case ENUMTY: {
- struct suedef *sue;
- sue = new < 0 ? pty->n_sue : p->ssue;
- al = sue->suealign;
- sz = sue->suesize;
- break;
- }
-
case CHAR:
case UCHAR:
al = ALCHAR;
@@ -1777,7 +1828,7 @@ tymerge(NODE *typ, NODE *idp)
idp->n_qual = DECQAL(idp->n_qual);
/* in case ctype has rewritten things */
- if ((t = BTYPE(idp->n_type)) != STRTY && t != UNIONTY && t != ENUMTY)
+ if ((t = BTYPE(idp->n_type)) != STRTY && t != UNIONTY)
idp->n_sue = MKSUE(t);
if (idp->n_op != NAME) {
@@ -1816,8 +1867,7 @@ arglist(NODE *n)
if (w->n_right->n_op == ELLIPSIS)
continue;
ty = w->n_right->n_type;
- if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
- BTYPE(ty) == ENUMTY)
+ if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY)
num++;
while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
ty = DECREF(ty);
@@ -1826,8 +1876,7 @@ arglist(NODE *n)
}
cnt++;
ty = w->n_type;
- if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
- BTYPE(ty) == ENUMTY)
+ if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY)
num++;
while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
ty = DECREF(ty);
@@ -1861,8 +1910,7 @@ arglist(NODE *n)
ap[j]->n_type = INCREF(ap[j]->n_type);
ty = ap[j]->n_type;
al[k++].type = ty;
- if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
- BTYPE(ty) == ENUMTY)
+ if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY)
al[k++].sue = ap[j]->n_sue;
while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
ty = DECREF(ty);
@@ -2124,7 +2172,7 @@ alprint(union arglist *al, int in)
if (ISARY(al->type)) {
printf(" dim %d\n", al->df->ddim);
} else if (BTYPE(al->type) == STRTY ||
- BTYPE(al->type) == UNIONTY || BTYPE(al->type) == ENUMTY) {
+ BTYPE(al->type) == UNIONTY) {
al++;
printf(" (size %d align %d)", al->sue->suesize,
al->sue->suealign);
@@ -2311,9 +2359,6 @@ incomp: uerror("incompatible types for arg %d",
} else
goto out;
}
- if (BTYPE(arrt) == ENUMTY && BTYPE(type) == INT &&
- (arrt & ~BTMASK) == (type & ~BTMASK))
- goto skip; /* XXX enumty destroyed in optim() */
if (BTYPE(arrt) == VOID && type > BTMASK)
goto skip; /* void *f = some pointer */
if (arrt > BTMASK && BTYPE(type) == VOID)
@@ -2546,10 +2591,6 @@ fixclass(int class, TWORD type)
if( !(instruct&INSTRUCT) ) uerror( "illegal MOS class" );
return( class );
- case MOE:
- if( instruct & (INSTRUCT|INUNION) ) uerror( "illegal MOE class" );
- return( class );
-
case REGISTER:
if (blevel == 0)
uerror( "illegal register declaration" );
@@ -2576,7 +2617,6 @@ fixclass(int class, TWORD type)
}
case STNAME:
case UNAME:
- case ENAME:
case EXTERN:
case STATIC:
case EXTDEF:
diff --git a/usr.bin/pcc/ccom/trees.c b/usr.bin/pcc/ccom/trees.c
index 790e4099466..1fa2ecc9c74 100644
--- a/usr.bin/pcc/ccom/trees.c
+++ b/usr.bin/pcc/ccom/trees.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trees.c,v 1.8 2007/11/17 12:00:37 ragge Exp $ */
+/* $OpenBSD: trees.c,v 1.9 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -72,7 +72,6 @@
# include <stdarg.h>
static void chkpun(NODE *p);
-static int chkenum(int, int, NODE *p);
static int opact(NODE *p);
static int moditype(TWORD);
static NODE *strargs(NODE *);
@@ -335,13 +334,11 @@ runtime:
p->n_sue = sp->ssue;
p->n_lval = 0;
p->n_sp = sp;
- /* special case: MOETY is really an ICON... */
- if (p->n_type == MOETY) {
- p->n_sp = NULL;
+ if (sp->sclass == MOE) {
+ p->n_op = ICON;
p->n_lval = sp->soffset;
p->n_df = NULL;
- p->n_type = ENUMTY;
- p->n_op = ICON;
+ p->n_sp = NULL;
}
break;
@@ -759,16 +756,6 @@ chkpun(NODE *p)
if (BTYPE(t2) == VOID && (t1 & TMASK))
return;
- /* check for enumerations */
- if (t1 == ENUMTY || t2 == ENUMTY) {
- if (clogop(p->n_op) && p->n_op != EQ && p->n_op != NE) {
- werror("comparison of enums");
- return;
- }
- if (chkenum(t1, t2, p))
- return;
- }
-
if (ISPTR(t1) || ISARY(t1))
q = p->n_right;
else
@@ -805,9 +792,6 @@ chkpun(NODE *p)
}
++d1;
++d2;
- } else if (t1 == ENUMTY || t2 == ENUMTY) {
- chkenum(t1, t2, p);
- return;
} else
break;
t1 = DECREF(t1);
@@ -817,22 +801,6 @@ chkpun(NODE *p)
}
}
-static int
-chkenum(int t1, int t2, NODE *p)
-{
- if (t1 == ENUMTY && t2 == ENUMTY) {
- if (p->n_left->n_sue != p->n_right->n_sue)
- werror("enumeration type clash, operator %s", copst(p->n_op));
- return 1;
- }
- if ((t1 == ENUMTY && !(t2 >= CHAR && t2 <= UNSIGNED)) ||
- (t2 == ENUMTY && !(t1 >= CHAR && t1 <= UNSIGNED))) {
- werror("illegal combination of enum and non-integer type");
- return 1;
- }
- return 0;
-}
-
NODE *
stref(NODE *p)
{
@@ -1024,34 +992,6 @@ convert(NODE *p, int f)
return(p);
}
-/*
- * change enums to ints, or appropriate types
- */
-void
-econvert( p ) register NODE *p; {
-
-
- register TWORD ty;
-
- if( (ty=BTYPE(p->n_type)) == ENUMTY || ty == MOETY ) {
- if (p->n_sue->suesize == SZCHAR)
- ty = INT;
- else if (p->n_sue->suesize == SZINT)
- ty = INT;
- else if (p->n_sue->suesize == SZSHORT)
- ty = INT;
- else if (p->n_sue->suesize == SZLONGLONG)
- ty = LONGLONG;
- else
- ty = LONG;
- ty = ctype(ty);
- p->n_sue = MKSUE(ty);
- MODTYPE(p->n_type,ty);
- if (p->n_op == ICON && ty != LONG && ty != LONGLONG)
- p->n_type = INT, p->n_sue = MKSUE(INT);
- }
-}
-
NODE *
pconvert( p ) register NODE *p; {
@@ -1213,10 +1153,6 @@ tymatch(p) register NODE *p; {
t2 = DEUNSIGN(t2);
}
- if (t1 == ENUMTY || t1 == MOETY)
- t1 = INT; /* XXX */
- if (t2 == ENUMTY || t2 == MOETY)
- t2 = INT; /* XXX */
#if 0
if ((t1 == CHAR || t1 == SHORT) && o!= RETURN)
t1 = INT;
@@ -1295,8 +1231,6 @@ NODE *
makety(NODE *p, TWORD t, TWORD q, union dimfun *d, struct suedef *sue)
{
- if (p->n_type == ENUMTY && p->n_op == ICON)
- econvert(p);
if (t == p->n_type) {
p->n_df = d;
p->n_sue = sue;
@@ -1411,7 +1345,6 @@ icons(p) register NODE *p; {
# define MSTR 04 /* structure */
# define MPTR 010 /* pointer */
# define MPTI 020 /* pointer or integer */
-# define MENU 040 /* enumeration variable or member */
int
opact(NODE *p)
@@ -1457,8 +1390,6 @@ opact(NODE *p)
case MUL:
case DIV:
- if ((mt1&MDBI) && (mt2&MENU)) return( TYMATCH );
- if ((mt2&MDBI) && (mt1&MENU)) return( TYMATCH );
if( mt12 & MDBI ) return( TYMATCH );
break;
@@ -1487,7 +1418,6 @@ opact(NODE *p)
case QUEST:
case COMOP:
- if( mt2&MENU ) return( TYPR+NCVTR );
return( TYPR );
case STREF:
@@ -1509,12 +1439,6 @@ opact(NODE *p)
if( mt12 & MSTR ) return( LVAL+NCVT+TYPL+OTHER );
case CAST:
if( mt12 & MDBI ) return( TYPL+LVAL+TYMATCH );
-#if 0
- else if(mt1&MENU && mt2&MDBI) return( TYPL+LVAL+TYMATCH );
- else if(mt2&MENU && mt1&MDBI) return( TYPL+LVAL+TYMATCH );
- else if( (mt1&MENU)||(mt2&MENU) )
- return( LVAL+NCVT+TYPL+PTMATCH+PUN );
-#endif
else if( mt1 & MPTR) return( LVAL+PTMATCH+PUN );
else if( mt12 & MPTI ) return( TYPL+LVAL+TYMATCH+PUN );
break;
@@ -1571,10 +1495,6 @@ moditype(TWORD ty)
{
switch (ty) {
- case ENUMTY:
- case MOETY:
- return( MENU|MINT|MDBI|MPTI );
-
case STRTY:
case UNIONTY:
return( MSTR );
diff --git a/usr.bin/pcc/hppa/local.c b/usr.bin/pcc/hppa/local.c
index f1b29522f87..2e2c1d43519 100644
--- a/usr.bin/pcc/hppa/local.c
+++ b/usr.bin/pcc/hppa/local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local.c,v 1.1 2007/11/16 08:36:23 otto Exp $ */
+/* $OpenBSD: local.c,v 1.2 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2007 Michael Shalayeff
@@ -280,8 +280,6 @@ clocal(NODE *p)
case UNSIGNED:
l->n_lval = val & 0xffffffff;
break;
- case ENUMTY:
- case MOETY:
case LONG:
case INT:
l->n_lval = (int)val;
diff --git a/usr.bin/pcc/i386/code.c b/usr.bin/pcc/i386/code.c
index f0f9478af88..faed14036bc 100644
--- a/usr.bin/pcc/i386/code.c
+++ b/usr.bin/pcc/i386/code.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: code.c,v 1.3 2007/11/16 09:00:12 otto Exp $ */
+/* $OpenBSD: code.c,v 1.4 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -69,27 +69,19 @@ efcode()
{
extern int gotnr;
NODE *p, *q;
- int sz;
gotnr = 0; /* new number for next fun */
if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
return;
- /* address of return struct is in eax */
- /* create a call to memcpy() */
- /* will get the result in eax */
- p = block(REG, NIL, NIL, CHAR+PTR, 0, MKSUE(CHAR+PTR));
- p->n_rval = EAX;
- q = block(OREG, NIL, NIL, CHAR+PTR, 0, MKSUE(CHAR+PTR));
+ /* Create struct assignment */
+ q = block(OREG, NIL, NIL, PTR+STRTY, 0, cftnsp->ssue);
q->n_rval = EBP;
q->n_lval = 8; /* return buffer offset */
- p = block(CM, q, p, INT, 0, MKSUE(INT));
- sz = (tsize(STRTY, cftnsp->sdf, cftnsp->ssue)+SZCHAR-1)/SZCHAR;
- p = block(CM, p, bcon(sz), INT, 0, MKSUE(INT));
- p->n_right->n_name = "";
- p = block(CALL, bcon(0), p, CHAR+PTR, 0, MKSUE(CHAR+PTR));
- p->n_left->n_name = "memcpy";
- p = clocal(p);
- send_passt(IP_NODE, p);
+ q = buildtree(UMUL, q, NIL);
+ p = block(REG, NIL, NIL, PTR+STRTY, 0, cftnsp->ssue);
+ p = buildtree(UMUL, p, NIL);
+ p = buildtree(ASSIGN, q, p);
+ ecomp(p);
}
/*
diff --git a/usr.bin/pcc/i386/local.c b/usr.bin/pcc/i386/local.c
index bb5991974df..1f4d3f41462 100644
--- a/usr.bin/pcc/i386/local.c
+++ b/usr.bin/pcc/i386/local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local.c,v 1.3 2007/11/17 11:56:32 ragge Exp $ */
+/* $OpenBSD: local.c,v 1.4 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -318,8 +318,6 @@ clocal(NODE *p)
case UNSIGNED:
l->n_lval = val & 0xffffffff;
break;
- case ENUMTY:
- case MOETY:
case LONG:
case INT:
l->n_lval = (int)val;
diff --git a/usr.bin/pcc/mip/manifest.h b/usr.bin/pcc/mip/manifest.h
index 8d29e850653..0b8ed7827bf 100644
--- a/usr.bin/pcc/mip/manifest.h
+++ b/usr.bin/pcc/mip/manifest.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: manifest.h,v 1.6 2007/11/16 09:00:12 otto Exp $ */
+/* $OpenBSD: manifest.h,v 1.7 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
*
@@ -76,8 +76,8 @@
#define LDOUBLE 14
#define STRTY 15
#define UNIONTY 16
-#define ENUMTY 17
-#define MOETY 18 /* member of enum */
+/* #define ENUMTY 17 */
+/* #define MOETY 18 */ /* member of enum */
#define VOID 19
#define MAXTYPES 19 /* highest type+1 to be used by lang code */
diff --git a/usr.bin/pcc/mip/match.c b/usr.bin/pcc/mip/match.c
index 1f759df8945..d6cfa617a6e 100644
--- a/usr.bin/pcc/mip/match.c
+++ b/usr.bin/pcc/mip/match.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: match.c,v 1.4 2007/11/17 12:46:03 otto Exp $ */
+/* $OpenBSD: match.c,v 1.5 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -62,7 +62,7 @@
# include "pass2.h"
-#include <string.h>
+#include <strings.h>
void prttype(int t);
void setclass(int tmp, int class);
diff --git a/usr.bin/pcc/mips/local.c b/usr.bin/pcc/mips/local.c
index 113e420ce6e..0df1346481c 100644
--- a/usr.bin/pcc/mips/local.c
+++ b/usr.bin/pcc/mips/local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local.c,v 1.2 2007/11/16 08:34:55 otto Exp $ */
+/* $OpenBSD: local.c,v 1.3 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -251,8 +251,6 @@ clocal(NODE *p)
case UNSIGNED:
l->n_lval = val & 0xffffffff;
break;
- case ENUMTY:
- case MOETY:
case LONG:
case INT:
l->n_lval = (int)val;
diff --git a/usr.bin/pcc/nova/local.c b/usr.bin/pcc/nova/local.c
index cc820543051..3597402d4fa 100644
--- a/usr.bin/pcc/nova/local.c
+++ b/usr.bin/pcc/nova/local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local.c,v 1.1 2007/10/07 17:58:51 otto Exp $ */
+/* $OpenBSD: local.c,v 1.2 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -243,8 +243,6 @@ clocal(NODE *p)
case UNSIGNED:
l->n_lval = val & 0xffffffff;
break;
- case ENUMTY:
- case MOETY:
case LONG:
case INT:
l->n_lval = (int)val;
diff --git a/usr.bin/pcc/pdp10/local.c b/usr.bin/pcc/pdp10/local.c
index c9bfa0a83c0..cf95e0f7a8d 100644
--- a/usr.bin/pcc/pdp10/local.c
+++ b/usr.bin/pcc/pdp10/local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local.c,v 1.2 2007/11/16 09:00:13 otto Exp $ */
+/* $OpenBSD: local.c,v 1.3 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -262,8 +262,6 @@ rmpc: l->n_type = p->n_type;
case UNSIGNED:
l->n_lval = val & 0777777777777LL;
break;
- case ENUMTY:
- case MOETY:
case INT:
l->n_lval = val & 0777777777777LL;
if (val & 0400000000000LL)
diff --git a/usr.bin/pcc/powerpc/local.c b/usr.bin/pcc/powerpc/local.c
index ad596384cf7..64cc3598536 100644
--- a/usr.bin/pcc/powerpc/local.c
+++ b/usr.bin/pcc/powerpc/local.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: local.c,v 1.3 2007/11/01 10:52:58 otto Exp $ */
+/* $OpenBSD: local.c,v 1.4 2007/11/18 17:39:55 ragge Exp $ */
/*
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
@@ -404,8 +404,6 @@ clocal(NODE *p)
case UNSIGNED:
l->n_lval = val & 0xffffffff;
break;
- case ENUMTY:
- case MOETY:
case LONG:
case INT:
l->n_lval = (int)val;