aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/expr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r--gcc/d/expr.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 20ab49d..ac3d4aa 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -620,6 +620,18 @@ public:
break;
case TOKdiv:
+ /* Determine if the div expression is a lowered pointer diff operation.
+ The front-end rewrites `(p1 - p2)' into `(p1 - p2) / stride'. */
+ if (MinExp *me = e->e1->isMinExp ())
+ {
+ if (me->e1->type->ty == Tpointer && me->e2->type->ty == Tpointer
+ && e->e2->op == TOKint64)
+ {
+ code = EXACT_DIV_EXPR;
+ break;
+ }
+ }
+
code = e->e1->type->isintegral ()
? TRUNC_DIV_EXPR : RDIV_EXPR;
break;