tccpe: improve dllimport/export and use for tcc_add_symbol

This commit is contained in:
grischka
2010-01-14 20:55:51 +01:00
parent bdb9387a74
commit 2341ee5142
7 changed files with 178 additions and 134 deletions

View File

@ -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)
}
}
}