Support struct arguments with stdarg.h

- add __builtin_va_arg_types to check how arguments were passed
- move most code of stdarg into libtcc1.c
- remove __builtin_malloc and __builtin_free
- add a test case based on the bug report
  (http://www.mail-archive.com/tinycc-devel@nongnu.org/msg03036.html)
This commit is contained in:
Shinichiro Hamaji
2010-12-28 19:32:40 +09:00
parent 07fd82b411
commit 0ed7ba3f5e
5 changed files with 135 additions and 54 deletions

View File

@ -3542,12 +3542,28 @@ ST_FUNC void unary(void)
}
break;
#ifdef TCC_TARGET_X86_64
case TOK_builtin_malloc:
tok = TOK_malloc;
goto tok_identifier;
case TOK_builtin_free:
tok = TOK_free;
goto tok_identifier;
case TOK_builtin_va_arg_types:
{
/* This definition must be synced with stdarg.h */
enum __va_arg_type {
__va_gen_reg, __va_float_reg, __va_stack
};
CType type;
int bt;
next();
skip('(');
parse_type(&type);
skip(')');
bt = type.t & VT_BTYPE;
if (bt == VT_STRUCT || bt == VT_LDOUBLE) {
vpushi(__va_stack);
} else if (bt == VT_FLOAT || bt == VT_DOUBLE) {
vpushi(__va_float_reg);
} else {
vpushi(__va_gen_reg);
}
}
break;
#endif
case TOK_INC:
case TOK_DEC: