From 2341ee5142c184e06964f66696ebf88931953e7d Mon Sep 17 00:00:00 2001 From: grischka Date: Thu, 14 Jan 2010 20:55:51 +0100 Subject: tccpe: improve dllimport/export and use for tcc_add_symbol --- tccgen.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index b608c1f..be8d80f 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1343,10 +1343,8 @@ static void gen_opic(int op) } goto general_case; } else if (c2 && (op == '+' || op == '-') && - (((vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM) - && !(vtop[-1].sym->type.t & VT_IMPORT)) - || - (vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_LOCAL)) { + (((vtop[-1].r & (VT_VALMASK | VT_LVAL | VT_SYM)) == (VT_CONST | VT_SYM)) + || (vtop[-1].r & (VT_VALMASK | VT_LVAL)) == VT_LOCAL)) { /* symbol + constant case */ if (op == '-') l2 = -l2; @@ -2973,7 +2971,7 @@ static void post_type(CType *type, AttributeDef *ad) type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT); if ((pt.t & VT_BTYPE) == VT_VOID) error("parameter declared as void"); - arg_size += (type_size(&pt, &align) + 3) & ~3; + arg_size += (type_size(&pt, &align) + PTR_SIZE - 1) / PTR_SIZE; } else { old_proto: n = tok; @@ -5284,6 +5282,12 @@ ST_FUNC void decl(int l) func_decl_list(sym); } +#ifdef TCC_TARGET_PE + if (ad.func_import) + type.t |= VT_IMPORT; + if (ad.func_export) + type.t |= VT_EXPORT; +#endif if (tok == '{') { if (l == VT_LOCAL) error("cannot use local functions"); @@ -5402,10 +5406,6 @@ ST_FUNC void decl(int l) /* NOTE: as GCC, uninitialized global static arrays of null size are considered as extern */ -#ifdef TCC_TARGET_PE - if (ad.func_import) - type.t |= VT_IMPORT; -#endif external_sym(v, &type, r); } else { type.t |= (btype.t & VT_STATIC); /* Retain "static". */ @@ -5415,12 +5415,7 @@ ST_FUNC void decl(int l) r |= l; if (has_init) next(); -#ifdef TCC_TARGET_PE - if (ad.func_export) - type.t |= VT_EXPORT; -#endif - decl_initializer_alloc(&type, &ad, r, - has_init, v, l); + decl_initializer_alloc(&type, &ad, r, has_init, v, l); } } if (tok != ',') { @@ -5432,4 +5427,3 @@ ST_FUNC void decl(int l) } } } - -- cgit v1.3.1