aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2007-12-26 05:21:37 +0000
committerSeo Sanghyeon <sanxiyn@gmail.com>2007-12-26 05:21:37 +0000
commit9bb947adc5641938bd72c247ff353721160eea70 (patch)
treeb2b9c1065e774545950a89ae98e2c03b6473429b
parent4c92b433836fbcf65e33cca28866909e8fa472a9 (diff)
Remove broken assert from CodeGen. Better check is done in Sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45358 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--CodeGen/CGExprScalar.cpp5
-rw-r--r--test/CodeGen/pointer-arithmetic.c2
2 files changed, 3 insertions, 4 deletions
diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp
index f20c43f522..81a0cedf4e 100644
--- a/CodeGen/CGExprScalar.cpp
+++ b/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/test/CodeGen/pointer-arithmetic.c b/test/CodeGen/pointer-arithmetic.c
index 6c644c6e06..6b4de91112 100644
--- a/test/CodeGen/pointer-arithmetic.c
+++ b/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; }