diff --git a/tcc.h b/tcc.h index 3f7d43b..33fbef9 100644 --- a/tcc.h +++ b/tcc.h @@ -738,7 +738,9 @@ struct TCCState { #define VT_CMP 0x0033 /* the value is stored in processor flags (in vc) */ #define VT_JMP 0x0034 /* value is the consequence of jmp true (even) */ #define VT_JMPI 0x0035 /* value is the consequence of jmp false (odd) */ +#ifdef TCC_TARGET_X86_64 #define VT_REF 0x0040 /* value is pointer to structure rather than address */ +#endif #define VT_LVAL 0x0100 /* var is an lvalue */ #define VT_SYM 0x0200 /* a symbol value is added */ #define VT_MUSTCAST 0x0400 /* value must be casted to be correct (used for diff --git a/tccgen.c b/tccgen.c index 510051a..6151e4c 100644 --- a/tccgen.c +++ b/tccgen.c @@ -683,8 +683,10 @@ static void move_reg(int r, int s, int t) /* get address of vtop (vtop MUST BE an lvalue) */ static void gaddrof(void) { +#ifdef TCC_TARGET_X86_64 if (vtop->r & VT_REF) gv(RC_INT); +#endif vtop->r &= ~VT_LVAL; /* tricky: if saved lvalue, then we can go back to lvalue */ if ((vtop->r & VT_VALMASK) == VT_LLOCAL) @@ -889,13 +891,12 @@ ST_FUNC int gv(int rc) t = vtop->type.t; t1 = t; /* compute memory access type */ - if (vtop->r & VT_REF) #ifdef TCC_TARGET_X86_64 + if (vtop->r & VT_REF) t = VT_PTR; -#else - t = VT_INT; + else #endif - else if (vtop->r & VT_LVAL_BYTE) + if (vtop->r & VT_LVAL_BYTE) t = VT_BYTE; else if (vtop->r & VT_LVAL_SHORT) t = VT_SHORT; @@ -3863,7 +3864,11 @@ ST_FUNC void unary(void) skip(')'); if ((vtop->r & VT_VALMASK) != VT_LOCAL) tcc_error("__builtin_va_start expects a local variable"); +#ifdef TCC_TARGET_X86_64 vtop->r &= ~(VT_LVAL | VT_REF); +#else + vtop->r &= ~VT_LVAL; +#endif vtop->type = char_pointer_type; vstore(); }