Merge dmd-1.073.

This commit is contained in:
kai
2012-02-23 20:41:22 +01:00
parent 53f9964b95
commit a23b837ebd
38 changed files with 2262 additions and 1340 deletions

View File

@@ -1,6 +1,6 @@
// Compiler implementation of the D programming language
// Copyright (c) 1999-2011 by Digital Mars
// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
@@ -122,11 +122,11 @@ Expression *StructLiteralExp::optimize(int result)
if (elements)
{
for (size_t i = 0; i < elements->dim; i++)
{ Expression *e = (Expression *)elements->data[i];
{ Expression *e = (*elements)[i];
if (!e)
continue;
e = e->optimize(WANTvalue | (result & WANTinterpret));
elements->data[i] = (void *)e;
(*elements)[i] = e;
}
}
return this;
@@ -329,20 +329,20 @@ Expression *NewExp::optimize(int result)
if (newargs)
{
for (size_t i = 0; i < newargs->dim; i++)
{ Expression *e = (Expression *)newargs->data[i];
{ Expression *e = newargs->tdata()[i];
e = e->optimize(WANTvalue);
newargs->data[i] = (void *)e;
newargs->tdata()[i] = e;
}
}
if (arguments)
{
for (size_t i = 0; i < arguments->dim; i++)
{ Expression *e = (Expression *)arguments->data[i];
{ Expression *e = arguments->tdata()[i];
e = e->optimize(WANTvalue);
arguments->data[i] = (void *)e;
arguments->tdata()[i] = e;
}
}
return this;
@@ -357,10 +357,10 @@ Expression *CallExp::optimize(int result)
if (arguments)
{
for (size_t i = 0; i < arguments->dim; i++)
{ Expression *e = (Expression *)arguments->data[i];
{ Expression *e = arguments->tdata()[i];
e = e->optimize(WANTvalue);
arguments->data[i] = (void *)e;
arguments->tdata()[i] = e;
}
}
@@ -466,8 +466,8 @@ Expression *BinExp::optimize(int result)
{
dinteger_t i2 = e2->toInteger();
d_uns64 sz = e1->type->size() * 8;
if (i2 < 0 || i2 > sz)
{ error("shift assign by %jd is outside the range 0..%zu", i2, sz);
if (i2 < 0 || i2 >= sz)
{ error("shift assign by %jd is outside the range 0..%zu", i2, sz - 1);
e2 = new IntegerExp(0);
}
}
@@ -561,8 +561,8 @@ Expression *shift_optimize(int result, BinExp *e, Expression *(*shift)(Type *, E
{
dinteger_t i2 = e->e2->toInteger();
d_uns64 sz = e->e1->type->size() * 8;
if (i2 < 0 || i2 > sz)
{ e->error("shift by %jd is outside the range 0..%zu", i2, sz);
if (i2 < 0 || i2 >= sz)
{ e->error("shift by %jd is outside the range 0..%zu", i2, sz - 1);
e->e2 = new IntegerExp(0);
}
if (e->e1->isConst() == 1)
@@ -641,13 +641,10 @@ Expression *CommaExp::optimize(int result)
e = interpret(NULL);
return (e == EXP_CANT_INTERPRET) ? this : e;
}
// Don't constant fold if it is a compiler-generated temporary.
if (e1->op == TOKdeclaration)
return this;
e1 = e1->optimize(result & WANTinterpret);
e2 = e2->optimize(result);
if (!e1 || e1->op == TOKint64 || e1->op == TOKfloat64 || !e1->checkSideEffect(2))
if (!e1 || e1->op == TOKint64 || e1->op == TOKfloat64 || !e1->hasSideEffect())
{
e = e2;
if (e)
@@ -784,8 +781,12 @@ Expression *AndAndExp::optimize(int result)
e = this;
if (e1->isBool(FALSE))
{
e = new CommaExp(loc, e1, new IntegerExp(loc, 0, type));
e->type = type;
if (type->toBasetype()->ty == Tvoid)
e = e2;
else
{ e = new CommaExp(loc, e1, new IntegerExp(loc, 0, type));
e->type = type;
}
e = e->optimize(result);
}
else
@@ -802,7 +803,11 @@ Expression *AndAndExp::optimize(int result)
e = new IntegerExp(loc, n1 && n2, type);
}
else if (e1->isBool(TRUE))
e = new BoolExp(loc, e2, type);
{
if (type->toBasetype()->ty == Tvoid)
e = e2;
else e = new BoolExp(loc, e2, type);
}
}
}
return e;
@@ -833,7 +838,12 @@ Expression *OrOrExp::optimize(int result)
e = new IntegerExp(loc, n1 || n2, type);
}
else if (e1->isBool(FALSE))
e = new BoolExp(loc, e2, type);
{
if (type->toBasetype()->ty == Tvoid)
e = e2;
else
e = new BoolExp(loc, e2, type);
}
}
}
return e;