Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wilson committed May 2, 2012
2 parents d7aaa69 + be5a37b commit 24152fc
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/backend/rtlsym.h
Expand Up @@ -80,6 +80,8 @@ SYMBOL_MARS(DHIDDENFUNC, FLfunc,FREGSAVED,"_d_hidden_func", 0, t) \
SYMBOL_MARS(NEWCLASS, FLfunc,FREGSAVED,"_d_newclass", 0, t) \
SYMBOL_MARS(NEWARRAYT, FLfunc,FREGSAVED,"_d_newarrayT", 0, t) \
SYMBOL_MARS(NEWARRAYIT, FLfunc,FREGSAVED,"_d_newarrayiT", 0, t) \
SYMBOL_MARS(NEWITEMT, FLfunc,FREGSAVED,"_d_newitemT", 0, t) \
SYMBOL_MARS(NEWITEMIT, FLfunc,FREGSAVED,"_d_newitemiT", 0, t) \
SYMBOL_MARS(NEWARRAYMT, FLfunc,FREGSAVED,"_d_newarraymT", 0, tv) \
SYMBOL_MARS(NEWARRAYMIT, FLfunc,FREGSAVED,"_d_newarraymiT", 0, tv) \
SYMBOL_MARS(ARRAYLITERALT, FLfunc,FREGSAVED,"_d_arrayliteralT", 0, tv) \
Expand Down
7 changes: 4 additions & 3 deletions src/cast.c
Expand Up @@ -900,6 +900,9 @@ Expression *Expression::castTo(Scope *sc, Type *t)
}
else if (tb->ty == Tvector && typeb->ty != Tvector)
{
//printf("test1 e = %s, e->type = %s, tb = %s\n", e->toChars(), e->type->toChars(), tb->toChars());
TypeVector *tv = (TypeVector *)tb;
e = new CastExp(loc, e, tv->elementType());
e = new VectorExp(loc, e, tb);
e = e->semantic(sc);
return e;
Expand Down Expand Up @@ -1700,14 +1703,12 @@ Expression *FuncExp::inferType(Type *to, int flag, TemplateParameters *tparams)
to->ty == Tdelegate)
{
Type *typen = type->nextOf();
assert(typen->deco);
//if (typen->covariant(to->nextOf()) == 1)
if (typen->deco)
{
FuncExp *fe = (FuncExp *)copy();
fe->tok = TOKdelegate;
fe->type = (new TypeDelegate(typen))->merge();
e = fe;
//e = fe->Expression::implicitCastTo(sc, to);
}
}
else
Expand Down
11 changes: 11 additions & 0 deletions src/declaration.c
Expand Up @@ -544,6 +544,17 @@ void AliasDeclaration::semantic(Scope *sc)
s->parent = sc->parent;
}
}
OverloadSet *o = s->toAlias()->isOverloadSet();
if (o)
{
if (overnext)
{
o->push(overnext);
overnext = NULL;
s = o;
s->parent = sc->parent;
}
}
if (overnext)
ScopeDsymbol::multiplyDefined(0, this, overnext);
if (s == this)
Expand Down
2 changes: 2 additions & 0 deletions src/dsymbol.c
Expand Up @@ -1151,6 +1151,8 @@ int ScopeDsymbol::foreach(Scope *sc, Dsymbols *members, ScopeDsymbol::ForeachDg
result = foreach(sc, tm->members, dg, ctx, &n);
else if (s->isTemplateInstance())
;
else if (s->isUnitTestDeclaration())
;
else
result = dg(ctx, n++, s);

Expand Down
28 changes: 8 additions & 20 deletions src/e2ir.c
Expand Up @@ -1756,17 +1756,11 @@ elem *NewExp::toElem(IRState *irs)
{
d_uns64 elemsize = cd->size(loc);

// call _d_newarrayT(ti, 1)
e = el_long(TYsize_t, 1);
e = el_param(e, type->getTypeInfo(NULL)->toElem(irs));

int rtl = t->isZeroInit() ? RTLSYM_NEWARRAYT : RTLSYM_NEWARRAYIT;
e = el_bin(OPcall,TYdarray,el_var(rtlsym[rtl]),e);
// call _d_newitemT(ti)
e = type->getTypeInfo(NULL)->toElem(irs);

// The new functions return an array, so convert to a pointer
// ex -> (unsigned)(e >> 32)
e = el_bin(OPshr, TYdarray, e, el_long(TYint, PTRSIZE * 8));
ex = el_una(OP64_32, TYnptr, e);
int rtl = t->isZeroInit() ? RTLSYM_NEWITEMT : RTLSYM_NEWITEMIT;
ex = el_bin(OPcall,TYnptr,el_var(rtlsym[rtl]),e);

ectype = NULL;

Expand Down Expand Up @@ -1846,17 +1840,11 @@ elem *NewExp::toElem(IRState *irs)
Expression *di = tp->next->defaultInit();
d_uns64 disize = di->type->size();

// call _d_newarrayT(ti, 1)
e = el_long(TYsize_t, 1);
e = el_param(e, type->getTypeInfo(NULL)->toElem(irs));

int rtl = tp->next->isZeroInit() ? RTLSYM_NEWARRAYT : RTLSYM_NEWARRAYIT;
e = el_bin(OPcall,TYdarray,el_var(rtlsym[rtl]),e);
// call _d_newitemT(ti)
e = type->getTypeInfo(NULL)->toElem(irs);

// The new functions return an array, so convert to a pointer
// e -> (unsigned)(e >> 32)
e = el_bin(OPshr, TYdarray, e, el_long(TYsize_t, PTRSIZE * 8));
e = el_una(I64 ? OP128_64 : OP64_32, t->totym(), e);
int rtl = tp->next->isZeroInit() ? RTLSYM_NEWITEMT : RTLSYM_NEWITEMIT;
e = el_bin(OPcall,TYnptr,el_var(rtlsym[rtl]),e);
}
else
{
Expand Down
19 changes: 17 additions & 2 deletions src/expression.c
Expand Up @@ -5238,6 +5238,12 @@ Expression *FuncExp::semantic(Scope *sc, Expressions *arguments)

TypeFunction *tfl = (TypeFunction *)fd->type;
size_t dim = Parameter::dim(tfl->parameters);
if (arguments->dim < dim)
{ // Default arguments are always typed, so they don't need inference.
Parameter *p = Parameter::getNth(tfl->parameters, arguments->dim);
if (p->defaultArg)
dim = arguments->dim;
}

if ((!tfl->varargs && arguments->dim == dim) ||
( tfl->varargs && arguments->dim >= dim))
Expand Down Expand Up @@ -7864,6 +7870,7 @@ Expression *CallExp::semantic(Scope *sc)
{
e1 = new DotVarExp(loc, dte->e1, f);
e1 = e1->semantic(sc);
ue = (UnaExp *)e1;
}
#if 0
printf("ue->e1 = %s\n", ue->e1->toChars());
Expand Down Expand Up @@ -8061,7 +8068,15 @@ Expression *CallExp::semantic(Scope *sc)
{
TypeFunction *tf;
const char *p;
if (t1->ty == Tdelegate)
if (e1->op == TOKfunction)
{
// function literal that direct called is always inferred.
assert(((FuncExp *)e1)->fd);
f = ((FuncExp *)e1)->fd;
tf = (TypeFunction *)f->type;
p = "function literal";
}
else if (t1->ty == Tdelegate)
{ TypeDelegate *td = (TypeDelegate *)t1;
assert(td->next->ty == Tfunction);
tf = (TypeFunction *)(td->next);
Expand Down Expand Up @@ -8992,7 +9007,7 @@ VectorExp::VectorExp(Loc loc, Expression *e, Type *t)
: UnaExp(loc, TOKvector, sizeof(VectorExp), e)
{
assert(t->ty == Tvector);
to = t;
to = (TypeVector *)t;
dim = ~0;
}

Expand Down
4 changes: 3 additions & 1 deletion src/expression.h
Expand Up @@ -18,6 +18,7 @@
#include "intrange.h"

struct Type;
struct TypeVector;
struct Scope;
struct TupleDeclaration;
struct VarDeclaration;
Expand Down Expand Up @@ -1088,14 +1089,15 @@ struct CastExp : UnaExp

struct VectorExp : UnaExp
{
Type *to;
TypeVector *to; // the target vector type before semantic()
unsigned dim; // number of elements in the vector

VectorExp(Loc loc, Expression *e, Type *t);
Expression *syntaxCopy();
Expression *semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
elem *toElem(IRState *irs);
dt_t **toDt(dt_t **pdt);
};

struct SliceExp : UnaExp
Expand Down
16 changes: 12 additions & 4 deletions src/template.c
Expand Up @@ -4488,19 +4488,27 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs)
}
else
{
/* Find template declaration first.
*/
tempdecl = findTemplateDeclaration(sc);
if (!tempdecl)
{ inst = this;
//printf("error return %p, %d\n", tempdecl, global.errors);
return; // error recovery
}

/* Run semantic on each argument, place results in tiargs[]
* (if we havetempdecl, then tiargs is already evaluated)
* (if we have tempdecl, then tiargs is already evaluated)
*/
semanticTiargs(sc);
if (arrayObjectIsError(tiargs))
{ inst = this;
//printf("error return %p, %d\n", tempdecl, global.errors);
return; // error recovery
}

unsigned errs = global.errors;
tempdecl = findTemplateDeclaration(sc);
if (tempdecl)
tempdecl = findBestMatch(sc, fargs);
tempdecl = findBestMatch(sc, fargs);
if (!tempdecl || (errs != global.errors))
{ inst = this;
//printf("error return %p, %d\n", tempdecl, global.errors);
Expand Down
10 changes: 10 additions & 0 deletions src/todt.c
Expand Up @@ -799,6 +799,16 @@ dt_t **FuncExp::toDt(dt_t **pdt)
return dtxoff(pdt, s, 0, TYnptr);
}

dt_t **VectorExp::toDt(dt_t **pdt)
{
//printf("VectorExp::toDt() %s\n", toChars());
for (unsigned i = 0; i < dim; i++)
{
pdt = e1->toDt(pdt);
}
return pdt;
}

/* ================================================================= */

// Generate the data for the static initializer.
Expand Down
10 changes: 10 additions & 0 deletions test/runnable/funclit.d
Expand Up @@ -547,6 +547,15 @@ void test7761()
assert(dg7761(10) == 20);
}

/***************************************************/
// 8005

void test8005()
{
auto n = (a, int n = 2){ return n; }(1);
assert(n == 2);
}

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

int main()
Expand Down Expand Up @@ -578,6 +587,7 @@ int main()
test7713();
test7743();
test7761();
test8005();

printf("Success\n");
return 0;
Expand Down
19 changes: 19 additions & 0 deletions test/runnable/mixin2.d
Expand Up @@ -160,6 +160,25 @@ void test10()
mixin(null);
}

/*********************************************/
// 7560

class Base7560
{
template getter(T)
{
void get(ref T[] i, uint n) {}
}
mixin getter!uint;
mixin getter!char;
}

class Derived7560 : Base7560
{
alias Base7560.get get;
void get(ref char[] x) {}
}

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

void main()
Expand Down
17 changes: 17 additions & 0 deletions test/runnable/test7618.d
@@ -0,0 +1,17 @@
interface ITest
{
int foo();

final void bar(int k)() { assert(foo() == k); }
}

class Test : ITest
{
override int foo() { return 12; }
}

void main()
{
auto test = new Test;
test.bar!12();
}
71 changes: 71 additions & 0 deletions test/runnable/testxmm.d
Expand Up @@ -4,6 +4,8 @@ version (D_SIMD)
{

import core.simd;
import core.stdc.string;
import std.stdio;

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

Expand Down Expand Up @@ -606,6 +608,73 @@ void test7951_2()

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

void test7949()
{
int[4] o = [1,2,3,4];
int4 v1;
v1.array = o;
int4 v2;
v2.array = o;



auto r = __simd(XMM.ADDPS, v1,v2);

writeln(r.array);
}

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

immutable ulong2 gulong2 = 0x8000_0000_0000_0000;
immutable uint4 guint4 = 0x8000_0000;
immutable ushort8 gushort8 = 0x8000;
immutable ubyte16 gubyte16 = 0x80;

immutable long2 glong2 = 0x7000_0000_0000_0000;
immutable int4 gint4 = 0x7000_0000;
immutable short8 gshort8 = 0x7000;
immutable byte16 gbyte16 = 0x70;

immutable float4 gfloat4 = 4.0;
immutable double2 gdouble2 = 8.0;

void test7414()
{
immutable ulong2 lulong2 = 0x8000_0000_0000_0000;
assert(memcmp(&lulong2, &gulong2, gulong2.sizeof) == 0);

immutable uint4 luint4 = 0x8000_0000;
assert(memcmp(&luint4, &guint4, guint4.sizeof) == 0);

immutable ushort8 lushort8 = 0x8000;
assert(memcmp(&lushort8, &gushort8, gushort8.sizeof) == 0);

immutable ubyte16 lubyte16 = 0x80;
assert(memcmp(&lubyte16, &gubyte16, gubyte16.sizeof) == 0);


immutable long2 llong2 = 0x7000_0000_0000_0000;
assert(memcmp(&llong2, &glong2, glong2.sizeof) == 0);

immutable int4 lint4 = 0x7000_0000;
assert(memcmp(&lint4, &gint4, gint4.sizeof) == 0);

immutable short8 lshort8 = 0x7000;
assert(memcmp(&lshort8, &gshort8, gshort8.sizeof) == 0);

immutable byte16 lbyte16 = 0x70;
assert(memcmp(&lbyte16, &gbyte16, gbyte16.sizeof) == 0);


immutable float4 lfloat4 = 4.0;
assert(memcmp(&lfloat4, &gfloat4, gfloat4.sizeof) == 0);

immutable double2 ldouble2 = 8.0;
assert(memcmp(&ldouble2, &gdouble2, gdouble2.sizeof) == 0);
}

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

int main()
{
test1();
Expand All @@ -626,6 +695,8 @@ int main()

test7951();
test7951_2();
test7949();
test7414();

return 0;
}
Expand Down

0 comments on commit 24152fc

Please sign in to comment.