Skip to content

Commit

Permalink
More preferable fix
Browse files Browse the repository at this point in the history
[To be squashed.]

I assume a DotVar expression making it here implies its address is not
constant.
  • Loading branch information
kinke committed Sep 28, 2018
1 parent d2453e7 commit b59a261
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions gen/toconstelem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ class ToConstElemVisitor : public Visitor {
dinteger_t idx = undoStrideMul(e->loc, t1b, e->e2->toInteger());
result = llvm::ConstantExpr::getGetElementPtr(
isaPointer(ptr)->getElementType(), ptr, DtoConstSize_t(idx));
} else {
e->error("expression `%s` is not a constant", e->toChars());
fatalError(e);
return;
}

visit(static_cast<Expression *>(e));
}

void visit(MinExp *e) override {
Expand All @@ -247,10 +247,10 @@ class ToConstElemVisitor : public Visitor {
llvm::Constant *negIdx = llvm::ConstantExpr::getNeg(DtoConstSize_t(idx));
result = llvm::ConstantExpr::getGetElementPtr(
isaPointer(ptr)->getElementType(), ptr, negIdx);
} else {
e->error("expression `%s` is not a constant", e->toChars());
fatalError(e);
return;
}

visit(static_cast<Expression *>(e));
}

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -438,12 +438,12 @@ class ToConstElemVisitor : public Visitor {
return;
}

if (e->e1->op == TOKslice) {
e->error("non-constant expression `%s`", e->toChars());
} else {
e->error("constant expression `%s` not yet implemented", e->toChars());
if (e->e1->op == TOKslice || e->e1->op == TOKdotvar) {
visit(static_cast<Expression *>(e));
return;
}
fatalError(e);

llvm_unreachable("unsupported AddrExp in ToConstElemVisitor");
}

//////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit b59a261

Please sign in to comment.