Skip to content

Commit

Permalink
Merge pull request #3786 from 9rnsr/2.066
Browse files Browse the repository at this point in the history
Cherry-picking commits from master to 2.066 branch (for beta5)
  • Loading branch information
WalterBright committed Jul 20, 2014
2 parents b717c19 + 2bbe5ee commit 120cae6
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/backend/cod4.c
Expand Up @@ -2902,10 +2902,10 @@ code *cdshtlng(elem *e,regm_t *pretregs)
if (op == OPu16_32 && c1)
{
code *cx = code_last(c1);
if (cx->Iop == 0x81 && (cx->Irm & modregrm(3,7,0)) == modregrm(3,4,0))
if (cx->Iop == 0x81 && (cx->Irm & modregrm(3,7,0)) == modregrm(3,4,0) &&
mask[cx->Irm & 7] == retregs)
{
// Convert AND of a word to AND of a dword, zeroing upper word
retregs = mask[cx->Irm & 7];
if (cx->Irex & REX_B)
retregs = mask[8 | (cx->Irm & 7)];
cx->Iflags &= ~CFopsize;
Expand Down
20 changes: 20 additions & 0 deletions src/cast.c
Expand Up @@ -141,6 +141,26 @@ Expression *implicitCastTo(Expression *e, Scope *sc, Type *t)
if (tb->ty == Tarray)
semanticTypeInfo(sc, ((TypeDArray *)tb)->next);
}

void visit(SliceExp *e)
{
visit((Expression *)e);
if (result->op != TOKslice)
return;

e = (SliceExp *)result;
if (e->e1->op == TOKarrayliteral)
{
ArrayLiteralExp *ale = (ArrayLiteralExp *)e->e1;
Type *tb = t->toBasetype();
Type *tx;
if (tb->ty == Tsarray)
tx = tb->nextOf()->sarrayOf(ale->elements ? ale->elements->dim : 0);
else
tx = tb->nextOf()->arrayOf();
e->e1 = ale->implicitCastTo(sc, tx);
}
}
};

ImplicitCastTo v(sc, t);
Expand Down
4 changes: 3 additions & 1 deletion src/class.c
Expand Up @@ -671,7 +671,9 @@ void ClassDeclaration::semantic(Scope *sc)
if (baseClass)
{
alignsize = baseClass->alignsize;
structsize = (baseClass->structsize + alignsize - 1) & ~(alignsize - 1);
structsize = baseClass->structsize;
if (cpp && global.params.isWindows)
structsize = (structsize + alignsize - 1) & ~(alignsize - 1);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/mars.c
Expand Up @@ -475,7 +475,7 @@ Usage:\n\
-version=level compile in version code >= level\n\
-version=ident compile in version code identified by ident\n\
-vtls list all variables going into thread local storage\n\
-vgc list all hidden gc allocations\n\
-vgc list all gc allocations including hidden ones\n\
-w warnings as errors (compilation will halt)\n\
-wi warnings as messages (compilation will continue)\n\
-X generate JSON file\n\
Expand Down
38 changes: 38 additions & 0 deletions test/runnable/cppa.d
Expand Up @@ -337,6 +337,43 @@ void test12825()

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

extern(C++) class C13161
{
void dummyfunc() {}
long val_5;
uint val_9;
}

extern(C++) class Test : C13161
{
uint val_0;
long val_1;
}

extern(C++) size_t getoffset13161();

extern(C++) class C13161a
{
void dummyfunc() {}
real val_5;
uint val_9;
}

extern(C++) class Testa : C13161a
{
bool val_0;
}

extern(C++) size_t getoffset13161a();

void test13161()
{
assert(getoffset13161() == Test.val_0.offsetof);
assert(getoffset13161a() == Testa.val_0.offsetof);
}

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

void main()
{
test1();
Expand All @@ -354,6 +391,7 @@ void main()
test11();
testvalist();
test12825();
test13161();

printf("Success\n");
}
43 changes: 43 additions & 0 deletions test/runnable/extra-files/cppb.cpp
Expand Up @@ -234,3 +234,46 @@ void myvprintf(const char* format, va_list va)
{
myvprintfx(format, va);
}

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

class C13161
{
public:
virtual void dummyfunc() {}
long long val_5;
unsigned val_9;
};

class Test : public C13161
{
public:
unsigned val_0;
long long val_1;
};

size_t getoffset13161()
{
Test s;
return (char *)&s.val_0 - (char *)&s;
}

class C13161a
{
public:
virtual void dummyfunc() {}
long double val_5;
unsigned val_9;
};

class Testa : public C13161a
{
public:
bool val_0;
};

size_t getoffset13161a()
{
Testa s;
return (char *)&s.val_0 - (char *)&s;
}
24 changes: 24 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -1086,6 +1086,29 @@ int bug8525(int[] devt)
return devt[$ - 1];
}

////////////////////////////////////////////////////////////////////////

void test12833a(int a)
{
long x = cast(long)a;

switch (cast(int)(cast(ushort)(x >> 16 & 65535L)))
{
case 1:
{
break;
}
default:
{
assert(0);
}
}
}

void test12833()
{
test12833a(0x1_0000);
}

////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1119,6 +1142,7 @@ int main()
test10715();
test10678();
test7565();
test12833();
printf("Success\n");
return 0;
}
2 changes: 1 addition & 1 deletion test/runnable/test12.d
Expand Up @@ -781,7 +781,7 @@ void test36()
printf("%d\n", a.d);

version(D_LP64)
assert(a.classinfo.init.length == 40);
assert(a.classinfo.init.length == 36);
else
assert(a.classinfo.init.length == 28);
assert(a.s == 1);
Expand Down
17 changes: 17 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -6938,6 +6938,22 @@ void test12937()
assert((cast(ubyte[])sa2[])[0] == 1);
}

/***************************************************/
// 13154

void test13154()
{
int[3] ints = [2 , 1 , 0 , 1 ][0..3];
float[3] floats0 = [2f , 1f , 0f , 1f ][0..3];
float[3] floats1 = [2.0 , 1.0 , 0.0 , 1.0 ][0..3]; // fails!
float[3] floats2 = [2.0f, 1.0f, 0.0f, 1.0f][0..3];
assert(ints == [2, 1, 0]);
assert(floats0 == [2, 1, 0]);
assert(floats1 == [2, 1, 0]); // fail!
assert(floats1 != [0, 0, 0]); // fail!
assert(floats2 == [2, 1, 0]);
}

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

int main()
Expand Down Expand Up @@ -7225,6 +7241,7 @@ int main()
test11317();
test12153();
test12937();
test13154();

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

0 comments on commit 120cae6

Please sign in to comment.