diff options
| -rw-r--r-- | c/c.c | 10 | ||||
| -rw-r--r-- | common.h | 4 | ||||
| -rw-r--r-- | io.c | 1 | ||||
| -rw-r--r-- | targ.c | 5 |
4 files changed, 14 insertions, 6 deletions
@@ -3995,11 +3995,19 @@ function(struct comp *cm, struct function *fn, const char **pnames, const struct void docomp(struct comp *cm) { + static union type valistty; struct token tk[1]; if (!cm->env) cm->env = &toplevel; - putdecl(cm, &(struct decl) { mktype(TYVALIST), SCTYPEDEF, .name = intern("__builtin_va_list") }); + if (!valistty.t) { + struct typedata td = { + .t = TYSTRUCT, .siz = targ_valistsize, .align = targ_primalign[TYPTR], .nmemb = 1, + .fld = (struct namedfield [1]){{"?"}} + }; + valistty = mktagtype(intern("__builtin_va_list"), &td); + } + putdecl(cm, &(struct decl) { valistty, SCTYPEDEF, .name = intern("__builtin_va_list") }); while (peek(cm, tk) != TKEOF) { struct declstate st = { DTOPLEVEL }; @@ -160,7 +160,6 @@ enum typetag { /* ordering is important here! */ TYBOOL, TYCHAR, TYSCHAR, TYUCHAR, TYSHORT, TYUSHORT, TYINT, TYUINT, TYLONG, TYULONG, TYVLONG, TYUVLONG, TYFLOAT, TYDOUBLE, TYLDOUBLE, TYVOID, - TYVALIST, TYPTR, TYARRAY, TYFUNC, TYSTRUCT, TYUNION, NTYPETAG, @@ -193,7 +192,7 @@ union type { uint bits; }; -#define isprimt(t) in_range((t), TYBOOL, TYVALIST) +#define isprimt(t) in_range((t), TYBOOL, TYVOID) #define isintt(t) in_range((t), TYENUM, TYUVLONG) #define issignedt(t) ((TYSIGNEDSET_ | targ_charsigned << TYCHAR) >> (t) & 1) #define isunsignedt(t) ((TYUNSIGNEDSET_ | !targ_charsigned << TYCHAR) >> (t) & 1) @@ -335,6 +334,7 @@ typearrlen(union type t) /* TARGET */ /**********/ +extern uint targ_valistsize; extern uchar targ_primsizes[]; extern uchar targ_primalign[]; extern enum typetag targ_sizetype, targ_ptrdifftype, targ_wchartype; @@ -210,7 +210,6 @@ pritypebefore(struct wbuf *buf, union type ty, int qual) case TYFLOAT: s = "float"; goto Prim; case TYDOUBLE: s = "double"; goto Prim; case TYLDOUBLE:s = "long double"; goto Prim; - case TYVALIST: s = "va_list"; goto Prim; case TYPTR: chld = typechild(ty); n = pritypebefore(buf, chld, ty.flag & TFCHLDQUAL); @@ -15,6 +15,7 @@ static const struct targ { uchar targ_primsizes[TYPTR+1]; uchar targ_primalign[TYPTR+1]; +uint targ_valistsize; enum typetag targ_sizetype, targ_ptrdifftype, targ_wchartype; bool targ_charsigned, targ_bigendian, targ_64bit; const struct mctarg *mctarg; @@ -35,12 +36,12 @@ targ_init(const char *starg) sizes[TYULONG] = sizes[TYLONG] = t->longsize; sizes[TYUVLONG] = sizes[TYVLONG] = t->vlongsize; sizes[TYPTR] = t->ptrsize; - sizes[TYVALIST] = t->valistsize; align[TYULONG] = align[TYLONG] = t->longalign; align[TYUVLONG] = align[TYVLONG] = t->vlongalign; align[TYDOUBLE] = t->doublealign; align[TYLDOUBLE] = t->doublealign; - align[TYVALIST] = align[TYPTR] = t->ptralign; + align[TYPTR] = t->ptralign; + targ_valistsize = t->valistsize; targ_sizetype = t->sizetype; targ_ptrdifftype = t->ptrdifftype; targ_wchartype = t->wchartype; |