History

avoid "decl after statement" please

for compiling tcc with msc

grischka committed 13 years ago

Commit be1b6ba1 parent 41b3c7a3 files · +20 −13Browse files

Unified · Split

3 files
  1. i386-gen.c +5 −2
  2. tccgen.c +6 −5
  3. x86_64-gen.c +9 −6
i386-gen.c+5−2
@@ -366,10 +366,12 @@ static uint8_t fastcall_regs[3] = { TREG_EAX, TREG_EDX, TREG_ECX }; · 365 unmodified lines
366366 static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX };
367367
368368 /* Return 1 if this function returns via an sret pointer, 0 otherwise */
369−ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
370− *ret_align = 1; // Never have to re-align return values for x86
369+ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align)
370+{
371371 #ifdef TCC_TARGET_PE
372372 int size, align;
373+
374+ *ret_align = 1; // Never have to re-align return values for x86
373375 size = type_size(vt, &align);
374376 if (size > 8) {
375377 return 1;
@@ -383,6 +385,7 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) { · 7 unmodified lines
383385 return 0;
384386 }
385387 #else
388+ *ret_align = 1; // Never have to re-align return values for x86
386389 return 1;
387390 #endif
388391 }
tccgen.c+6−5
@@ -3995,9 +3995,10 @@ ST_FUNC void unary(void) · 3994 unmodified lines
39953995 vtop->r2 = ret.r2;
39963996 /* handle packed struct return */
39973997 if (((s->type.t & VT_BTYPE) == VT_STRUCT) && !sret) {
3998+ int addr;
39983999 size = type_size(&s->type, &align);
39994000 loc = (loc - size) & -align;
4000− int addr = loc;
4001+ addr = loc;
40014002 vset(&ret.type, VT_LOCAL | VT_LVAL, addr);
40024003 vswap();
40034004 vstore();
@@ -4493,7 +4494,8 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 489 unmodified lines
44934494 gsym_addr(b, d);
44944495 } else if (tok == '{') {
44954496 Sym *llabel;
4496−
4497+ int block_vla_sp_loc, *saved_vla_sp_loc, saved_vla_flags;
4498+
44974499 next();
44984500 /* record local declaration stack position */
44994501 s = local_stack;
@@ -4503,12 +4505,11 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 3 unmodified lines
45034505 llabel = local_label_stack;
45044506
45054507 /* save VLA state */
4506− int block_vla_sp_loc = *vla_sp_loc;
4507− int *saved_vla_sp_loc = vla_sp_loc;
4508+ block_vla_sp_loc = *(saved_vla_sp_loc = vla_sp_loc);
45084509 if (saved_vla_sp_loc != &vla_sp_root_loc)
45094510 vla_sp_loc = &block_vla_sp_loc;
45104511
4511− int saved_vla_flags = vla_flags;
4512+ saved_vla_flags = vla_flags;
45124513 vla_flags |= VLA_NEED_NEW_FRAME;
45134514
45144515 /* handle local labels declarations */
x86_64-gen.c+9−6
@@ -664,9 +664,10 @@ void gen_offs_sp(int b, int r, int d) · 663 unmodified lines
664664 }
665665
666666 /* Return 1 if this function returns via an sret pointer, 0 otherwise */
667−ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
668− *ret_align = 1; // Never have to re-align return values for x86-64
667+ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align)
668+{
669669 int size, align;
670+ *ret_align = 1; // Never have to re-align return values for x86-64
670671 size = type_size(vt, &align);
671672 ret->ref = NULL;
672673 if (size > 8) {
@@ -687,9 +688,9 @@ ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) { · 14 unmodified lines
687688 }
688689
689690 int gfunc_arg_size(CType *type) {
691+ int align;
690692 if (type->t & (VT_ARRAY|VT_BITFIELD))
691693 return 8;
692− int align;
693694 return type_size(type, &align);
694695 }
695696
@@ -706,9 +707,10 @@ void gfunc_call(int nb_args) · 10 unmodified lines
706707 So, we process arguments which will be passed by stack first. */
707708 struct_size = args_size;
708709 for(i = 0; i < nb_args; i++) {
709− --arg;
710+ SValue *sv;
710711
711− SValue *sv = &vtop[-i];
712+ --arg;
713+ sv = &vtop[-i];
712714 bt = (sv->type.t & VT_BTYPE);
713715 size = gfunc_arg_size(&sv->type);
714716
@@ -2025,8 +2027,9 @@ void gen_cvt_ftof(int t) · 1310 unmodified lines
20252027 vtop->r = TREG_ST0;
20262028 }
20272029 } else {
2030+ int r;
20282031 gv(RC_ST0);
2029− int r = get_reg(RC_FLOAT);
2032+ r = get_reg(RC_FLOAT);
20302033 if (tbt == VT_DOUBLE) {
20312034 o(0xf0245cdd); /* fstpl -0x10(%rsp) */
20322035 /* movsd -0x10(%rsp),%xmm0 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t