Mercurial > projects > ldc
comparison gen/toir.cpp @ 574:aee6217b4084
Fixed pointer comparisons with differing types.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Thu, 04 Sep 2008 17:17:40 +0200 |
parents | 1b702422451c |
children | f0c20d50d4b3 |
comparison
equal
deleted
inserted
replaced
573:d300e9a049fa | 574:aee6217b4084 |
---|---|
1169 DValue* l = e1->toElem(p); | 1169 DValue* l = e1->toElem(p); |
1170 DValue* r = e2->toElem(p); | 1170 DValue* r = e2->toElem(p); |
1171 | 1171 |
1172 Type* t = e1->type->toBasetype(); | 1172 Type* t = e1->type->toBasetype(); |
1173 Type* e2t = e2->type->toBasetype(); | 1173 Type* e2t = e2->type->toBasetype(); |
1174 assert(DtoType(t) == DtoType(e2t)); | |
1175 | 1174 |
1176 LLValue* eval = 0; | 1175 LLValue* eval = 0; |
1177 | 1176 |
1178 if (t->isintegral() || t->ty == Tpointer) | 1177 if (t->isintegral() || t->ty == Tpointer) |
1179 { | 1178 { |
1219 { | 1218 { |
1220 LLValue* a = l->getRVal(); | 1219 LLValue* a = l->getRVal(); |
1221 LLValue* b = r->getRVal(); | 1220 LLValue* b = r->getRVal(); |
1222 Logger::cout() << "type 1: " << *a << '\n'; | 1221 Logger::cout() << "type 1: " << *a << '\n'; |
1223 Logger::cout() << "type 2: " << *b << '\n'; | 1222 Logger::cout() << "type 2: " << *b << '\n'; |
1223 if (a->getType() != b->getType()) | |
1224 b = DtoBitCast(b, a->getType()); | |
1224 eval = p->ir->CreateICmp(cmpop, a, b, "tmp"); | 1225 eval = p->ir->CreateICmp(cmpop, a, b, "tmp"); |
1225 } | 1226 } |
1226 } | 1227 } |
1227 else if (t->isfloating()) | 1228 else if (t->isfloating()) |
1228 { | 1229 { |