summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/CodeGen/CGExprScalar.cpp5
-rw-r--r--clang/test/CodeGen/pointer-arithmetic.c2
2 files changed, 3 insertions, 4 deletions
diff --git a/clang/CodeGen/CGExprScalar.cpp b/clang/CodeGen/CGExprScalar.cpp
index f20c43f5228..81a0cedf4e9 100644
--- a/clang/CodeGen/CGExprScalar.cpp
+++ b/clang/CodeGen/CGExprScalar.cpp
@@ -756,10 +756,7 @@ Value *ScalarExprEmitter::VisitBinSub(const BinaryOperator *E) {
Value *RHS = Visit(E->getRHS());
const QualType LHSType = E->getLHS()->getType().getCanonicalType();
- const QualType RHSType = E->getRHS()->getType().getCanonicalType();
- assert(LHSType == RHSType && "Can't subtract different pointer types");
-
- QualType LHSElementType = cast<PointerType>(LHSType)->getPointeeType();
+ const QualType LHSElementType = cast<PointerType>(LHSType)->getPointeeType();
uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType,
SourceLocation()) / 8;
diff --git a/clang/test/CodeGen/pointer-arithmetic.c b/clang/test/CodeGen/pointer-arithmetic.c
index 6c644c6e06f..6b4de911128 100644
--- a/clang/test/CodeGen/pointer-arithmetic.c
+++ b/clang/test/CodeGen/pointer-arithmetic.c
@@ -3,3 +3,5 @@
typedef int Int;
int test1(int *a, Int *b) { return a - b; }
+
+int test2(const char *a, char *b) { return b - a; }
OpenPOWER on IntegriCloud