Ignore typedefs in pointer arithmetic codegen.

llvm-svn: 44529
This commit is contained in:
Seo Sanghyeon 2007-12-03 06:23:43 +00:00
parent 9050bd1f68
commit 3d072bea09
2 changed files with 9 additions and 4 deletions

View File

@ -697,11 +697,11 @@ Value *ScalarExprEmitter::VisitBinSub(const BinaryOperator *E) {
Value *LHS = Visit(E->getLHS());
Value *RHS = Visit(E->getRHS());
const PointerType *LHSPtrType = E->getLHS()->getType()->getAsPointerType();
assert(LHSPtrType == E->getRHS()->getType()->getAsPointerType() &&
"Can't subtract different pointer types");
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 = LHSPtrType->getPointeeType();
QualType LHSElementType = cast<PointerType>(LHSType)->getPointeeType();
uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType,
SourceLocation()) / 8;

View File

@ -0,0 +1,5 @@
// RUN: clang -emit-llvm %s
typedef int Int;
int test1(int *a, Int *b) { return a - b; }