mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-29 10:30:04 +02:00
Revert meaning of AddExp/MinExp for pointers to DMD default.
It might be worth considering to move the stride multiplication down to the glue layer in the upstream sources. But assigning a different meaning to AST nodes was a giant maintenance liability, especially with regard to CTFE.
This commit is contained in:
@@ -2005,10 +2005,7 @@ Expression *BinExp::scaleFactor(Scope *sc)
|
||||
stride = t1b->nextOf()->size(loc);
|
||||
if (!t->equals(t2b))
|
||||
e2 = e2->castTo(sc, t);
|
||||
// LDC: llvm uses typesafe pointer arithmetic
|
||||
#if !IN_LLVM
|
||||
e2 = new MulExp(loc, e2, new IntegerExp(0, stride, t));
|
||||
#endif
|
||||
eoff = e2;
|
||||
e2->type = t;
|
||||
type = e1->type;
|
||||
@@ -2024,9 +2021,7 @@ Expression *BinExp::scaleFactor(Scope *sc)
|
||||
e = e1->castTo(sc, t);
|
||||
else
|
||||
e = e1;
|
||||
#if !IN_LLVM
|
||||
e = new MulExp(loc, e, new IntegerExp(0, stride, t));
|
||||
#endif
|
||||
eoff = e;
|
||||
e->type = t;
|
||||
type = e2->type;
|
||||
|
||||
@@ -670,17 +670,10 @@ Expression *pointerArithmetic(Loc loc, enum TOK op, Type *type,
|
||||
Expression *val = agg1;
|
||||
TypeArray *tar = (TypeArray *)val->type;
|
||||
sinteger_t indx = ofs1;
|
||||
#if IN_LLVM // LDC: llvm uses typesafe pointer arithmetic
|
||||
if (op == TOKadd || op == TOKaddass || op == TOKplusplus)
|
||||
indx += ofs2;
|
||||
else if (op == TOKmin || op == TOKminass || op == TOKminusminus)
|
||||
indx -= ofs2;
|
||||
#else
|
||||
if (op == TOKadd || op == TOKaddass || op == TOKplusplus)
|
||||
indx = indx + ofs2/sz;
|
||||
else if (op == TOKmin || op == TOKminass || op == TOKminusminus)
|
||||
indx -= ofs2/sz;
|
||||
#endif
|
||||
else
|
||||
{
|
||||
error(loc, "CTFE Internal compiler error: bad pointer operation");
|
||||
|
||||
@@ -8973,17 +8973,9 @@ L1:
|
||||
{ /* The handle to the monitor (call it a void*)
|
||||
* *(cast(void**)e + 1)
|
||||
*/
|
||||
#if IN_LLVM
|
||||
e = e->castTo(sc, tint8->pointerTo()->pointerTo());
|
||||
e = new AddExp(e->loc, e, new IntegerExp(1));
|
||||
e->type = tint8->pointerTo();
|
||||
e = e->castTo(sc, tvoidptr->pointerTo());
|
||||
e = new PtrExp(e->loc, e);
|
||||
#else
|
||||
e = e->castTo(sc, tvoidptr->pointerTo());
|
||||
e = new AddExp(e->loc, e, new IntegerExp(1));
|
||||
e = new PtrExp(e->loc, e);
|
||||
#endif
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user