aboutsummaryrefslogtreecommitdiff
path: root/expr.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-09-07 12:50:50 -0700
committerMichael Forney <mforney@mforney.org>2021-09-07 13:19:19 -0700
commit97c8fc5358bbecb6e2452425861e6cd5a5c93f91 (patch)
tree8bebb448e9c460072bf4e2aa52dce138d9ffcd1c /expr.c
parent056c471bb7f85854e2af7a0166785d06820b251a (diff)
expr: Fix varargs again and add more tests
Diffstat (limited to 'expr.c')
-rw-r--r--expr.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/expr.c b/expr.c
index 323cbb7..d1458a4 100644
--- a/expr.c
+++ b/expr.c
@@ -645,7 +645,7 @@ builtinfunc(struct scope *s, enum builtinkind kind)
e->base = assignexpr(s);
if (!typesame(e->base->type, typeadjvalist))
error(&tok.loc, "va_arg argument must have type va_list");
- if (!e->base->decayed)
+ if (typeadjvalist == targ->typevalist)
e->base = mkunaryexpr(TBAND, e->base);
expect(TCOMMA, "after va_list");
e->type = typename(s, &e->qual);
@@ -655,14 +655,14 @@ builtinfunc(struct scope *s, enum builtinkind kind)
e->assign.l = assignexpr(s);
if (!typesame(e->assign.l->type, typeadjvalist))
error(&tok.loc, "va_copy destination must have type va_list");
- if (e->assign.l->decayed)
- e->assign.l = e->assign.l->base;
+ if (typeadjvalist != targ->typevalist)
+ e->assign.l = mkunaryexpr(TMUL, e->assign.l);
expect(TCOMMA, "after target va_list");
e->assign.r = assignexpr(s);
if (!typesame(e->assign.r->type, typeadjvalist))
error(&tok.loc, "va_copy source must have type va_list");
- if (e->assign.r->decayed)
- e->assign.r = e->assign.r->base;
+ if (typeadjvalist != targ->typevalist)
+ e->assign.r = mkunaryexpr(TMUL, e->assign.r);
break;
case BUILTINVAEND:
e = assignexpr(s);
@@ -677,7 +677,7 @@ builtinfunc(struct scope *s, enum builtinkind kind)
e->base = assignexpr(s);
if (!typesame(e->base->type, typeadjvalist))
error(&tok.loc, "va_start argument must have type va_list");
- if (!e->base->decayed)
+ if (typeadjvalist == targ->typevalist)
e->base = mkunaryexpr(TBAND, e->base);
expect(TCOMMA, "after va_list");
param = assignexpr(s);