Commit 255b2d91 by Iain Buclaw Committed by Iain Buclaw

Merge dmd upstream 180465274

Reduces the memory footprint of the CTFE interpreter by replacing new
with emplacement new in many places.

gcc/d/ChangeLog:

2019-01-21  Iain Buclaw  <ibuclaw@gdcproject.org>

	* d-frontend.cc (Compiler::paintAsType): Update for new signature.

From-SVN: r268124
parent d5011496
2019-01-21 Iain Buclaw <ibuclaw@gdcproject.org>
* d-frontend.cc (Compiler::paintAsType): Update for new signature.
2019-01-20 Iain Buclaw <ibuclaw@gdcproject.org>
* d-builtins.cc (d_init_versions): Check value of
......
......@@ -446,7 +446,7 @@ Compiler::genCmain (Scope *sc)
so we just lower the value to GCC and return the converted CST. */
Expression *
Compiler::paintAsType (Expression *expr, Type *type)
Compiler::paintAsType (UnionExp *, Expression *expr, Type *type)
{
/* We support up to 512-bit values. */
unsigned char buffer[64];
......
cd2034cd7b157dd8f3e94c684061bb1aa630b2b6
180465274b72a2ff218449f6793af0fbaabbcaa3
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
......@@ -19,6 +19,7 @@ class Expression;
class Module;
class Type;
struct Scope;
struct UnionExp;
// DMD-generated module `__entrypoint` where the C main resides
extern Module *entrypoint;
......@@ -28,7 +29,7 @@ extern Module *rootHasMain;
struct Compiler
{
// CTFE support for cross-compilation.
static Expression *paintAsType(Expression *, Type *);
static Expression *paintAsType(UnionExp *, Expression *, Type *);
// Backend
static void loadModule(Module *);
static void genCmain(Scope *);
......
......@@ -1457,8 +1457,7 @@ UnionExp Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr)
memcpy(elements->tdata(),
es1->elements->tdata() + ilwr,
(size_t)(iupr - ilwr) * sizeof((*es1->elements)[0]));
new(&ue) ArrayLiteralExp(e1->loc, elements);
ue.exp()->type = type;
new(&ue) ArrayLiteralExp(e1->loc, type, elements);
}
}
else
......@@ -1606,6 +1605,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
new(&ue) StringExp(loc, s, len);
StringExp *es = (StringExp *)ue.exp();
es->type = type;
es->sz = sz;
es->committed = 1;
}
......@@ -1614,9 +1614,8 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
// Create an ArrayLiteralExp
Expressions *elements = new Expressions();
elements->push(e);
new(&ue) ArrayLiteralExp(e->loc, elements);
new(&ue) ArrayLiteralExp(e->loc, type, elements);
}
ue.exp()->type = type;
assert(ue.exp()->type);
return ue;
}
......@@ -1627,8 +1626,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
// Handle null ~= null
if (t1->ty == Tarray && t2 == t1->nextOf())
{
new(&ue) ArrayLiteralExp(e1->loc, e2);
ue.exp()->type = type;
new(&ue) ArrayLiteralExp(e1->loc, type, e2);
assert(ue.exp()->type);
return ue;
}
......@@ -1695,9 +1693,8 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
{
(*elems)[i] = ea->getElement(i);
}
new(&ue) ArrayLiteralExp(e1->loc, elems);
new(&ue) ArrayLiteralExp(e1->loc, type, elems);
ArrayLiteralExp *dest = (ArrayLiteralExp *)ue.exp();
dest->type = type;
sliceAssignArrayLiteralFromString(dest, es, ea->elements->dim);
assert(ue.exp()->type);
return ue;
......@@ -1715,9 +1712,8 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
{
(*elems)[es->len + i] = ea->getElement(i);
}
new(&ue) ArrayLiteralExp(e1->loc, elems);
new(&ue) ArrayLiteralExp(e1->loc, type, elems);
ArrayLiteralExp *dest = (ArrayLiteralExp *)ue.exp();
dest->type = type;
sliceAssignArrayLiteralFromString(dest, es, 0);
assert(ue.exp()->type);
return ue;
......@@ -1783,7 +1779,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
// Concatenate the arrays
Expressions *elems = ArrayLiteralExp::copyElements(e1, e2);
new(&ue) ArrayLiteralExp(e1->loc, elems);
new(&ue) ArrayLiteralExp(e1->loc, NULL, elems);
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
......@@ -1809,7 +1805,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
// Concatenate the array with null
Expressions *elems = ArrayLiteralExp::copyElements(e);
new(&ue) ArrayLiteralExp(e->loc, elems);
new(&ue) ArrayLiteralExp(e->loc, NULL, elems);
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
......@@ -1829,7 +1825,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
? ArrayLiteralExp::copyElements(e1) : new Expressions();
elems->push(e2);
new(&ue) ArrayLiteralExp(e1->loc, elems);
new(&ue) ArrayLiteralExp(e1->loc, NULL, elems);
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
......@@ -1846,7 +1842,7 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
{
Expressions *elems = ArrayLiteralExp::copyElements(e1, e2);
new(&ue) ArrayLiteralExp(e2->loc, elems);
new(&ue) ArrayLiteralExp(e2->loc, NULL, elems);
e = ue.exp();
if (type->toBasetype()->ty == Tsarray)
......@@ -1874,9 +1870,8 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
{
Expressions *expressions = new Expressions();
expressions->push(e);
new(&ue) ArrayLiteralExp(loc, expressions);
new(&ue) ArrayLiteralExp(loc, t, expressions);
e = ue.exp();
e->type = t;
}
else
{
......
......@@ -134,6 +134,7 @@ UnionExp copyLiteral(Expression *e);
/// Set this literal to the given type, copying it if necessary
Expression *paintTypeOntoLiteral(Type *type, Expression *lit);
Expression *paintTypeOntoLiteral(UnionExp *pue, Type *type, Expression *lit);
UnionExp paintTypeOntoLiteralCopy(Type *type, Expression *lit);
/// Convert from a CTFE-internal slice, into a normal Expression
......@@ -143,11 +144,11 @@ Expression *resolveSlice(Expression *e, UnionExp *pue = NULL);
uinteger_t resolveArrayLength(Expression *e);
/// Create an array literal consisting of 'elem' duplicated 'dim' times.
ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Loc loc, Type *type,
ArrayLiteralExp *createBlockDuplicatedArrayLiteral(UnionExp *pue, Loc loc, Type *type,
Expression *elem, size_t dim);
/// Create a string literal consisting of 'value' duplicated 'dim' times.
StringExp *createBlockDuplicatedStringLiteral(Loc loc, Type *type,
StringExp *createBlockDuplicatedStringLiteral(UnionExp *pue, Loc loc, Type *type,
unsigned value, size_t dim, unsigned char sz);
......@@ -209,7 +210,7 @@ UnionExp pointerArithmetic(Loc loc, TOK op, Type *type,
bool isFloatIntPaint(Type *to, Type *from);
// Reinterpret float/int value 'fromVal' as a float/integer of type 'to'.
Expression *paintFloatInt(Expression *fromVal, Type *to);
Expression *paintFloatInt(UnionExp *pue, Expression *fromVal, Type *to);
/// Return true if t is an AA
bool isAssocArray(Type *t);
......@@ -264,4 +265,4 @@ UnionExp ctfeCat(Loc loc, Type *type, Expression *e1, Expression *e2);
Expression *ctfeIndex(Loc loc, Type *type, Expression *e1, uinteger_t indx);
/// Cast 'e' of type 'type' to type 'to'.
Expression *ctfeCast(Loc loc, Type *type, Type *to, Expression *e);
Expression *ctfeCast(UnionExp *pue, Loc loc, Type *type, Type *to, Expression *e);
......@@ -264,10 +264,9 @@ UnionExp copyLiteral(Expression *e)
ArrayLiteralExp *ale = (ArrayLiteralExp *)e;
Expressions *elements = copyLiteralArray(ale->elements, ale->basis);
new(&ue) ArrayLiteralExp(e->loc, elements);
new(&ue) ArrayLiteralExp(e->loc, e->type, elements);
ArrayLiteralExp *r = (ArrayLiteralExp *)ue.exp();
r->type = e->type;
r->ownedByCtfe = OWNEDctfe;
return ue;
}
......@@ -314,7 +313,10 @@ UnionExp copyLiteral(Expression *e)
{
TypeSArray *tsa = (TypeSArray *)v->type;
size_t len = (size_t)tsa->dim->toInteger();
m = createBlockDuplicatedArrayLiteral(e->loc, v->type, m, len);
UnionExp uex;
m = createBlockDuplicatedArrayLiteral(&uex, e->loc, v->type, m, len);
if (m == uex.exp())
m = uex.copy();
}
}
(*newelems)[i] = m;
......@@ -414,6 +416,14 @@ Expression *paintTypeOntoLiteral(Type *type, Expression *lit)
return paintTypeOntoLiteralCopy(type, lit).copy();
}
Expression *paintTypeOntoLiteral(UnionExp *pue, Type *type, Expression *lit)
{
if (lit->type->equals(type))
return lit;
*pue = paintTypeOntoLiteralCopy(type, lit);
return pue->exp();
}
UnionExp paintTypeOntoLiteralCopy(Type *type, Expression *lit)
{
UnionExp ue;
......@@ -539,6 +549,7 @@ uinteger_t resolveArrayLength(Expression *e)
* Helper for NewExp
* Create an array literal consisting of 'elem' duplicated 'dim' times.
* Params:
* pue = where to store result
* loc = source location where the interpretation occurs
* type = target type of the result
* elem = the source of array element, it will be owned by the result
......@@ -546,7 +557,7 @@ uinteger_t resolveArrayLength(Expression *e)
* Returns:
* Constructed ArrayLiteralExp
*/
ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Loc loc, Type *type,
ArrayLiteralExp *createBlockDuplicatedArrayLiteral(UnionExp *pue, Loc loc, Type *type,
Expression *elem, size_t dim)
{
if (type->ty == Tsarray && type->nextOf()->ty == Tsarray && elem->type->ty != Tsarray)
......@@ -554,7 +565,10 @@ ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Loc loc, Type *type,
// If it is a multidimensional array literal, do it recursively
TypeSArray *tsa = (TypeSArray *)type->nextOf();
size_t len = (size_t)tsa->dim->toInteger();
elem = createBlockDuplicatedArrayLiteral(loc, type->nextOf(), elem, len);
UnionExp ue;
elem = createBlockDuplicatedArrayLiteral(&ue, loc, type->nextOf(), elem, len);
if (elem == ue.exp())
elem = ue.copy();
}
// Buzilla 15681
......@@ -567,8 +581,8 @@ ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Loc loc, Type *type,
{
(*elements)[i] = mustCopy ? copyLiteral(elem).copy() : elem;
}
ArrayLiteralExp *ale = new ArrayLiteralExp(loc, elements);
ale->type = type;
new(pue) ArrayLiteralExp(loc, type, elements);
ArrayLiteralExp *ale = (ArrayLiteralExp *)pue->exp();
ale->ownedByCtfe = OWNEDctfe;
return ale;
}
......@@ -577,7 +591,7 @@ ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Loc loc, Type *type,
* Helper for NewExp
* Create a string literal consisting of 'value' duplicated 'dim' times.
*/
StringExp *createBlockDuplicatedStringLiteral(Loc loc, Type *type,
StringExp *createBlockDuplicatedStringLiteral(UnionExp *pue, Loc loc, Type *type,
unsigned value, size_t dim, unsigned char sz)
{
utf8_t *s = (utf8_t *)mem.xcalloc(dim + 1, sz);
......@@ -591,7 +605,8 @@ StringExp *createBlockDuplicatedStringLiteral(Loc loc, Type *type,
default: assert(0);
}
}
StringExp *se = new StringExp(loc, s, dim);
new(pue) StringExp(loc, s, dim);
StringExp *se = (StringExp *)pue->exp();
se->type = type;
se->sz = sz;
se->committed = true;
......@@ -984,13 +999,13 @@ bool isFloatIntPaint(Type *to, Type *from)
}
// Reinterpret float/int value 'fromVal' as a float/integer of type 'to'.
Expression *paintFloatInt(Expression *fromVal, Type *to)
Expression *paintFloatInt(UnionExp *pue, Expression *fromVal, Type *to)
{
if (exceptionOrCantInterpret(fromVal))
return fromVal;
assert(to->size() == 4 || to->size() == 8);
return Compiler::paintAsType(fromVal, to);
return Compiler::paintAsType(pue, fromVal, to);
}
/******** Constant folding, with support for CTFE ***************************/
......@@ -1512,10 +1527,9 @@ UnionExp ctfeCat(Loc loc, Type *type, Expression *e1, Expression *e2)
ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1;
ArrayLiteralExp *es2 = (ArrayLiteralExp *)e2;
new(&ue) ArrayLiteralExp(es1->loc, copyLiteralArray(es1->elements));
new(&ue) ArrayLiteralExp(es1->loc, type, copyLiteralArray(es1->elements));
es1 = (ArrayLiteralExp *)ue.exp();
es1->elements->insert(es1->elements->dim, copyLiteralArray(es2->elements));
es1->type = type;
return ue;
}
if (e1->op == TOKarrayliteral && e2->op == TOKnull &&
......@@ -1587,29 +1601,33 @@ Expression *ctfeIndex(Loc loc, Type *type, Expression *e1, uinteger_t indx)
}
}
Expression *ctfeCast(Loc loc, Type *type, Type *to, Expression *e)
Expression *ctfeCast(UnionExp *pue, Loc loc, Type *type, Type *to, Expression *e)
{
if (e->op == TOKnull)
return paintTypeOntoLiteral(to, e);
return paintTypeOntoLiteral(pue, to, e);
if (e->op == TOKclassreference)
{
// Disallow reinterpreting class casts. Do this by ensuring that
// the original class can implicitly convert to the target class
ClassDeclaration *originalClass = ((ClassReferenceExp *)e)->originalClass();
if (originalClass->type->implicitConvTo(to->mutableOf()))
return paintTypeOntoLiteral(to, e);
return paintTypeOntoLiteral(pue, to, e);
else
return new NullExp(loc, to);
{
new(pue) NullExp(loc, to);
return pue->exp();
}
}
// Allow TypeInfo type painting
if (isTypeInfo_Class(e->type) && e->type->implicitConvTo(to))
return paintTypeOntoLiteral(to, e);
return paintTypeOntoLiteral(pue, to, e);
// Allow casting away const for struct literals
if (e->op == TOKstructliteral &&
e->type->toBasetype()->castMod(0) == to->toBasetype()->castMod(0))
{
return paintTypeOntoLiteral(to, e);
}
return paintTypeOntoLiteral(pue, to, e);
Expression *r;
if (e->type->equals(type) && type->equals(to))
......@@ -1617,22 +1635,28 @@ Expression *ctfeCast(Loc loc, Type *type, Type *to, Expression *e)
// necessary not to change e's address for pointer comparisons
r = e;
}
else if (to->toBasetype()->ty == Tarray && type->toBasetype()->ty == Tarray &&
else if (to->toBasetype()->ty == Tarray &&
type->toBasetype()->ty == Tarray &&
to->toBasetype()->nextOf()->size() == type->toBasetype()->nextOf()->size())
{
// Bugzilla 12495: Array reinterpret casts: eg. string to immutable(ubyte)[]
return paintTypeOntoLiteral(to, e);
return paintTypeOntoLiteral(pue, to, e);
}
else
{
r = Cast(loc, type, to, e).copy();
*pue = Cast(loc, type, to, e);
r = pue->exp();
}
if (CTFEExp::isCantExp(r))
error(loc, "cannot cast %s to %s at compile time", e->toChars(), to->toChars());
if (e->op == TOKarrayliteral)
((ArrayLiteralExp *)e)->ownedByCtfe = OWNEDctfe;
if (e->op == TOKstring)
((StringExp *)e)->ownedByCtfe = OWNEDctfe;
return r;
}
......@@ -1816,9 +1840,8 @@ UnionExp changeArrayLiteralLength(Loc loc, TypeArray *arrayType,
for (size_t i = copylen; i < newlen; i++)
(*elements)[i] = defaultElem;
}
new(&ue) ArrayLiteralExp(loc, elements);
new(&ue) ArrayLiteralExp(loc, arrayType, elements);
ArrayLiteralExp *aae = (ArrayLiteralExp *)ue.exp();
aae->type = arrayType;
aae->ownedByCtfe = OWNEDctfe;
}
return ue;
......@@ -2078,9 +2101,8 @@ UnionExp voidInitLiteral(Type *t, VarDeclaration *var)
elem = copyLiteral(elem).copy();
(*elements)[i] = elem;
}
new(&ue) ArrayLiteralExp(var->loc, elements);
new(&ue) ArrayLiteralExp(var->loc, tsa, elements);
ArrayLiteralExp *ae = (ArrayLiteralExp *)ue.exp();
ae->type = tsa;
ae->ownedByCtfe = OWNEDctfe;
}
else if (t->ty == Tstruct)
......
......@@ -1189,23 +1189,26 @@ void ScopeDsymbol::importScope(Dsymbol *s, Prot protection)
}
}
#define BITS_PER_INDEX (sizeof(size_t) * CHAR_BIT)
static void bitArraySet(BitArray *array, size_t idx)
{
array->ptr[idx / (sizeof(size_t) * CHAR_BIT)] |= 1ULL << (idx & (sizeof(size_t) * CHAR_BIT - 1));
array->ptr[idx / BITS_PER_INDEX] |= 1ULL << (idx % BITS_PER_INDEX);
}
static bool bitArrayGet(BitArray *array, size_t idx)
{
return (array->ptr[idx / (sizeof(size_t) * CHAR_BIT)] & (1ULL << (idx & (sizeof(size_t) * CHAR_BIT - 1)))) != 0;
const size_t boffset = idx % BITS_PER_INDEX;
return (array->ptr[idx / BITS_PER_INDEX] & (1ULL << boffset)) >> boffset;
}
static void bitArrayLength(BitArray *array, size_t len)
{
size_t obytes = (array->len + CHAR_BIT - 1) / CHAR_BIT;
size_t nbytes = (len + CHAR_BIT - 1) / CHAR_BIT;
if (obytes < nbytes)
if (array->len < len)
{
const size_t obytes = (array->len + BITS_PER_INDEX - 1) / BITS_PER_INDEX;
const size_t nbytes = (len + BITS_PER_INDEX - 1) / BITS_PER_INDEX;
if (!array->ptr)
array->ptr = (size_t *)mem.xmalloc(nbytes * sizeof(size_t));
else
......@@ -1213,8 +1216,9 @@ static void bitArrayLength(BitArray *array, size_t len)
for (size_t i = obytes; i < nbytes; i++)
array->ptr[i] = 0;
array->len = nbytes * BITS_PER_INDEX;
}
array->len = len;
}
void ScopeDsymbol::addAccessiblePackage(Package *p, Prot protection)
......
......@@ -1493,7 +1493,6 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
* is now optimized. See Bugzilla 2356.
*/
Type *tbn = ((TypeArray *)tb)->next;
Type *tsa = tbn->sarrayOf(nargs - i);
Expressions *elements = new Expressions();
elements->setDim(nargs - i);
......@@ -1511,8 +1510,7 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
(*elements)[u] = a;
}
// Bugzilla 14395: Convert to a static array literal, or its slice.
arg = new ArrayLiteralExp(loc, elements);
arg->type = tsa;
arg = new ArrayLiteralExp(loc, tbn->sarrayOf(nargs - i), elements);
if (tb->ty == Tarray)
{
arg = new SliceExp(loc, arg, NULL, NULL);
......@@ -3741,34 +3739,37 @@ unsigned StringExp::charAt(uinteger_t i) const
// [ e1, e2, e3, ... ]
ArrayLiteralExp::ArrayLiteralExp(Loc loc, Expressions *elements)
ArrayLiteralExp::ArrayLiteralExp(Loc loc, Type *type, Expressions *elements)
: Expression(loc, TOKarrayliteral, sizeof(ArrayLiteralExp))
{
this->basis = NULL;
this->type = type;
this->elements = elements;
this->ownedByCtfe = OWNEDcode;
}
ArrayLiteralExp::ArrayLiteralExp(Loc loc, Expression *e)
ArrayLiteralExp::ArrayLiteralExp(Loc loc, Type *type, Expression *e)
: Expression(loc, TOKarrayliteral, sizeof(ArrayLiteralExp))
{
this->basis = NULL;
this->type = type;
elements = new Expressions;
elements->push(e);
this->ownedByCtfe = OWNEDcode;
}
ArrayLiteralExp::ArrayLiteralExp(Loc loc, Expression *basis, Expressions *elements)
ArrayLiteralExp::ArrayLiteralExp(Loc loc, Type *type, Expression *basis, Expressions *elements)
: Expression(loc, TOKarrayliteral, sizeof(ArrayLiteralExp))
{
this->basis = basis;
this->type = type;
this->elements = elements;
this->ownedByCtfe = OWNEDcode;
}
ArrayLiteralExp *ArrayLiteralExp::create(Loc loc, Expressions *elements)
{
return new ArrayLiteralExp(loc, elements);
return new ArrayLiteralExp(loc, NULL, elements);
}
bool ArrayLiteralExp::equals(RootObject *o)
......@@ -3806,6 +3807,7 @@ bool ArrayLiteralExp::equals(RootObject *o)
Expression *ArrayLiteralExp::syntaxCopy()
{
return new ArrayLiteralExp(loc,
NULL,
basis ? basis->syntaxCopy() : NULL,
arraySyntaxCopy(elements));
}
......@@ -4082,8 +4084,7 @@ Expression *StructLiteralExp::getField(Type *type, unsigned offset)
z->setDim(length);
for (size_t q = 0; q < length; ++q)
(*z)[q] = e->copy();
e = new ArrayLiteralExp(loc, z);
e->type = type;
e = new ArrayLiteralExp(loc, type, z);
}
else
{
......
......@@ -410,9 +410,9 @@ public:
Expressions *elements;
OwnedBy ownedByCtfe;
ArrayLiteralExp(Loc loc, Expressions *elements);
ArrayLiteralExp(Loc loc, Expression *e);
ArrayLiteralExp(Loc loc, Expression *basis, Expressions *elements);
ArrayLiteralExp(Loc loc, Type *type, Expressions *elements);
ArrayLiteralExp(Loc loc, Type *type, Expression *e);
ArrayLiteralExp(Loc loc, Type *type, Expression *basis, Expressions *elements);
static ArrayLiteralExp *create(Loc loc, Expressions *elements);
Expression *syntaxCopy();
bool equals(RootObject *o);
......
......@@ -6632,8 +6632,7 @@ public:
if (tb2->ty == Tarray || tb2->ty == Tsarray)
{
// Make e2 into [e2]
exp->e2 = new ArrayLiteralExp(exp->e2->loc, exp->e2);
exp->e2->type = exp->type;
exp->e2 = new ArrayLiteralExp(exp->e2->loc, exp->type, exp->e2);
}
result = exp->optimize(WANTvalue);
return;
......@@ -6669,8 +6668,7 @@ public:
if (tb1->ty == Tarray || tb1->ty == Tsarray)
{
// Make e1 into [e1]
exp->e1 = new ArrayLiteralExp(exp->e1->loc, exp->e1);
exp->e1->type = exp->type;
exp->e1 = new ArrayLiteralExp(exp->e1->loc, exp->type, exp->e1);
}
result = exp->optimize(WANTvalue);
return;
......
......@@ -267,6 +267,9 @@ Msgtable msgtable[] =
{ "_ArrayEq", NULL },
{ "_ArrayPostblit", NULL },
{ "_ArrayDtor", NULL },
{ "dup", NULL },
{ "_aaApply", NULL },
{ "_aaApply2", NULL },
// For pragma's
{ "Pinline", "inline" },
......
......@@ -612,7 +612,7 @@ public:
assert((*elements)[i]->op != TOKerror);
}
Expression *e = new ArrayLiteralExp(init->loc, elements);
Expression *e = new ArrayLiteralExp(init->loc, NULL, elements);
ExpInitializer *ei = new ExpInitializer(init->loc, e);
result = inferType(ei, sc);
return;
......@@ -857,8 +857,7 @@ public:
elements2->setDim(dim);
for (size_t j = 0; j < dim; j++)
(*elements2)[j] = e;
e = new ArrayLiteralExp(e->loc, elements2);
e->type = tn;
e = new ArrayLiteralExp(e->loc, tn, elements2);
(*elements)[i] = e;
}
}
......@@ -877,8 +876,7 @@ public:
}
}
Expression *e = new ArrayLiteralExp(init->loc, elements);
e->type = init->type;
Expression *e = new ArrayLiteralExp(init->loc, init->type, elements);
result = e;
return;
}
......@@ -902,8 +900,7 @@ public:
elements->setDim(d);
for (size_t i = 0; i < d; i++)
(*elements)[i] = e;
ArrayLiteralExp *ae = new ArrayLiteralExp(e->loc, elements);
ae->type = itype;
ArrayLiteralExp *ae = new ArrayLiteralExp(e->loc, itype, elements);
result = ae;
return;
}
......
......@@ -2324,16 +2324,11 @@ Identifier *Type::getTypeInfoIdent()
size_t namelen = 19 + sizeof(len) * 3 + len + 1;
char *name = namelen <= sizeof(namebuf) ? namebuf : (char *)mem.xmalloc(namelen);
sprintf(name, "_D%lluTypeInfo_%s6__initZ", (unsigned long long) 9 + len, buf.data);
int length = sprintf(name, "_D%lluTypeInfo_%s6__initZ", (unsigned long long) 9 + len, buf.data);
//printf("%p, deco = %s, name = %s\n", this, deco, name);
assert(strlen(name) < namelen); // don't overflow the buffer
assert(0 < length && length < namelen); // don't overflow the buffer
size_t off = 0;
#ifndef IN_GCC
if (global.params.isOSX || (global.params.isWindows && !global.params.is64bit))
++off; // C mangling will add '_' back in
#endif
Identifier *id = Identifier::idPool(name + off);
Identifier *id = Identifier::idPool(name, length);
if (name != namebuf)
free(name);
......@@ -4340,8 +4335,7 @@ Expression *TypeSArray::defaultInitLiteral(Loc loc)
elements->setDim(d);
for (size_t i = 0; i < d; i++)
(*elements)[i] = NULL;
ArrayLiteralExp *ae = new ArrayLiteralExp(Loc(), elementinit, elements);
ae->type = this;
ArrayLiteralExp *ae = new ArrayLiteralExp(Loc(), this, elementinit, elements);
return ae;
}
......
......@@ -7020,7 +7020,7 @@ Expression *Parser::parsePrimaryExp()
if (keys)
e = new AssocArrayLiteralExp(loc, keys, values);
else
e = new ArrayLiteralExp(loc, values);
e = new ArrayLiteralExp(loc, NULL, values);
break;
}
......
......@@ -479,8 +479,7 @@ Expression *pointerBitmap(TraitsExp *e)
for (d_uns64 i = 0; i < cntdata; i++)
exps->push(new IntegerExp(e->loc, data[(size_t)i], Type::tsize_t));
ArrayLiteralExp* ale = new ArrayLiteralExp(e->loc, exps);
ale->type = Type::tsize_t->sarrayOf(cntdata + 1);
ArrayLiteralExp* ale = new ArrayLiteralExp(e->loc, Type::tsize_t->sarrayOf(cntdata + 1), exps);
return ale;
}
......
......@@ -351,3 +351,24 @@ void test15789()
{
test15789a(0);
}
/**************************************/
// 7030
extern(C++)
{
struct T
{
void foo(int) const;
void bar(int);
static __gshared int boo;
}
}
version (Posix)
{
static assert(T.foo.mangleof == "_ZNK1T3fooEi");
static assert(T.bar.mangleof == "_ZN1T3barEi");
static assert(T.boo.mangleof == "_ZN1T3booE");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment