Showing with 78 additions and 5 deletions.
  1. +2 −1 src/backend/gloop.c
  2. +6 −4 src/cast.c
  3. +25 −0 test/runnable/template9.d
  4. +20 −0 test/runnable/test42.d
  5. +25 −0 test/runnable/xtest46.d
3 changes: 2 additions & 1 deletion src/backend/gloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,8 @@ STATIC void movelis(elem *n,block *b,loop *l,int *pdomexit)
// first block of the function. Unfortunately, the rd vector
// does not take this into account. Therefore, we assume the
// worst and reject assignments to function parameters.
if (v->Sclass == SCparameter || v->Sclass == SCregpar || v->Sclass == SCfastpar)
if (v->Sclass == SCparameter || v->Sclass == SCregpar ||
v->Sclass == SCfastpar || v->Sclass == SCshadowreg)
goto L3;

if (el_sideeffect(n->E2)) goto L3; // case 5
Expand Down
10 changes: 6 additions & 4 deletions src/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,8 +1312,7 @@ MATCH implicitConvTo(Expression *e, Type *t)

Type *tb = t->toBasetype();
Type *typeb = e->type->toBasetype();
if (tb->ty == Tsarray && typeb->ty == Tarray &&
e->lwr && e->upr)
if (tb->ty == Tsarray && typeb->ty == Tarray)
{
typeb = toStaticArrayType(e);
if (typeb)
Expand Down Expand Up @@ -2840,7 +2839,9 @@ bool typeMerge(Scope *sc, TOK op, Type **pt, Expression **pe1, Expression **pe2)
else if ((t1->ty == Tsarray || t1->ty == Tarray) &&
(m = t1->implicitConvTo(t2)) != MATCHnomatch)
{
if (t1->ty == Tsarray && e2->op == TOKarrayliteral)
// Bugzilla 7285: Tsarray op [x, y, ...] should to be Tsarray
// Bugzilla 14737: Tsarray ~ [x, y, ...] should to be Tarray
if (t1->ty == Tsarray && e2->op == TOKarrayliteral && op != TOKcat)
goto Lt1;
if (m == MATCHconst &&
(op == TOKaddass || op == TOKminass || op == TOKmulass ||
Expand All @@ -2856,7 +2857,8 @@ bool typeMerge(Scope *sc, TOK op, Type **pt, Expression **pe1, Expression **pe2)
}
else if ((t2->ty == Tsarray || t2->ty == Tarray) && t2->implicitConvTo(t1))
{
if (t2->ty == Tsarray && e1->op == TOKarrayliteral)
// Bugzilla 7285 & 14737
if (t2->ty == Tsarray && e1->op == TOKarrayliteral && op != TOKcat)
goto Lt2;
goto Lt1;
}
Expand Down
25 changes: 25 additions & 0 deletions test/runnable/template9.d
Original file line number Diff line number Diff line change
Expand Up @@ -4573,6 +4573,30 @@ template SubOps14568(Args...)

struct Nat14568 { mixin SubOps14568!(null); }

/******************************************/
// 14735

enum CS14735 { yes, no }

int indexOf14735a(Range )(Range s, in dchar c) { return 1; }
int indexOf14735a(T, size_t n)(ref T[n] s, in dchar c) { return 2; }

int indexOf14735b(Range )(Range s, in dchar c, in CS14735 cs = CS14735.yes) { return 1; }
int indexOf14735b(T, size_t n)(ref T[n] s, in dchar c, in CS14735 cs = CS14735.yes) { return 2; }

void test14735()
{
char[64] buf;

// Supported from 2.063: (http://dlang.org/changelog#implicitarraycast)
assert(indexOf14735a(buf[0..32], '\0') == 2);
assert(indexOf14735b(buf[0..32], '\0') == 2);

// Have to work as same as above.
assert(indexOf14735a(buf[], '\0') == 2);
assert(indexOf14735b(buf[], '\0') == 2);
}

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

int main()
Expand Down Expand Up @@ -4683,6 +4707,7 @@ int main()
test13379();
test13484();
test13694();
test14735();

printf("Success\n");
return 0;
Expand Down
20 changes: 20 additions & 0 deletions test/runnable/test42.d
Original file line number Diff line number Diff line change
Expand Up @@ -5994,6 +5994,25 @@ void test14430(){
setCookie();
}

/***************************************************/
// 14510

alias Vector14510 = ulong[3];

void fun14510(Vector14510 vec, bool recursive = false)
{
assert(vec[2] == 0);
if (recursive)
return;
fun14510(vec, true);
}

void test14510()
{
Vector14510 vec;
fun14510(vec);
}

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

int main()
Expand Down Expand Up @@ -6289,6 +6308,7 @@ int main()
test7436();
test12138();
test14430();
test14510();

writefln("Success");
return 0;
Expand Down
25 changes: 25 additions & 0 deletions test/runnable/xtest46.d
Original file line number Diff line number Diff line change
Expand Up @@ -5636,6 +5636,30 @@ void test7285()
auto sa = spam7285();
}

/***************************************************/
// 14737

void test14737()
{
// compile-time
enum string[2] a1 = ["d", "e"];
enum b1x = ["a", "b", "c"] ~ a1; // Tarray vs Tsarray
enum b1y = a1 ~ ["a", "b", "c"]; // Tsarray vs Tarray
static assert(is(typeof(b1x) == string[]));
static assert(is(typeof(b1y) == string[]));
static assert(b1x == ["a", "b", "c", "d", "e"]);
static assert(b1y == ["d", "e", "a", "b", "c"]);

// runtime
string[2] a2 = ["d", "e"];
auto b2x = ["a", "b", "c"] ~ a2; // Tarray vs Tsarray
auto b2y = a2 ~ ["a", "b", "c"]; // Tsarray vs Tarray
static assert(is(typeof(b2x) == string[]));
static assert(is(typeof(b2y) == string[]));
assert(b2x == ["a", "b", "c", "d", "e"]);
assert(b2y == ["d", "e", "a", "b", "c"]);
}

/***************************************************/
// 7321

Expand Down Expand Up @@ -7698,6 +7722,7 @@ int main()
test7170();
test7196();
test7285();
test14737();
test7321();
test3282();
test7534();
Expand Down