From 0ed7ba3f5e79f407a206b387079c9fd68327064b Mon Sep 17 00:00:00 2001 From: Shinichiro Hamaji Date: Tue, 28 Dec 2010 19:32:40 +0900 Subject: 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) --- tccgen.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index 82ec44f..3c6adbc 100644 --- a/tccgen.c +++ b/tccgen.c @@ -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: -- cgit v1.3.1