Skip to content

Commit

Permalink
Merge pull request #2354 from WalterBright/fix10634
Browse files Browse the repository at this point in the history
fix Issue 10634 - Win64: wrong codegen with .int of small structs
  • Loading branch information
rainers committed Jul 17, 2013
2 parents e4795a4 + 1b089fc commit 97b8437
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/backend/cgelem.c
Expand Up @@ -3020,8 +3020,6 @@ elem * elstruct(elem *e, goal_t goal)
return optelem(e, goal);
}

//printf("\tnumbytes = %d\n", (int)e->Enumbytes);

if (!e->ET)
return e;
//printf("\tnumbytes = %d\n", (int)type_size(e->ET));
Expand All @@ -3038,6 +3036,7 @@ elem * elstruct(elem *e, goal_t goal)
}

unsigned sz = type_size(e->ET);
//printf("\tsz = %d\n", (int)sz);
switch ((int)sz)
{
case 1: tym = TYchar; goto L1;
Expand All @@ -3052,7 +3051,7 @@ elem * elstruct(elem *e, goal_t goal)
case 6:
case 7: tym = TYllong;
L2:
if (config.exe == EX_WIN64)
if (e->Eoper == OPstrpar && config.exe == EX_WIN64)
{
goto L1;
}
Expand Down
32 changes: 32 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -6446,6 +6446,37 @@ void test10539()

/***************************************************/

struct TimeOfDay
{
ubyte h, m, s;
}

__gshared byte glob;

struct DateTime
{
this(ubyte _d, ubyte _m, ubyte _y, TimeOfDay _tod = TimeOfDay.init)
{
d = _d;
m = _m;
y = _y;
tod = _tod;
}
TimeOfDay tod;
ubyte d, m, y;
}


void test10634()
{
glob = 123;
DateTime date1 = DateTime(0, 0, 0);
DateTime date2;
assert(date1 == date2);
}

/***************************************************/

int main()
{
test1();
Expand Down Expand Up @@ -6715,6 +6746,7 @@ int main()
test9130();
test10542();
test10539();
test10634();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 97b8437

Please sign in to comment.