fix rdar://6774906, a crash handling implicit conversions between pointers

in different address spaces.

llvm-svn: 68941
This commit is contained in:
Chris Lattner 2009-04-13 06:04:39 +00:00
parent 184f1be4a8
commit 5c6160d019
2 changed files with 12 additions and 6 deletions

View File

@ -1956,11 +1956,10 @@ inline QualType::GCAttrTypes QualType::getObjCGCAttr() const {
/// "int". However, it is not more qualified than "const volatile
/// int".
inline bool QualType::isMoreQualifiedThan(QualType Other) const {
// FIXME: Handle address spaces
unsigned MyQuals = this->getCVRQualifiers();
unsigned OtherQuals = Other.getCVRQualifiers();
assert(this->getAddressSpace() == 0 && "Address space not checked");
assert(Other.getAddressSpace() == 0 && "Address space not checked");
if (getAddressSpace() != Other.getAddressSpace())
return false;
return MyQuals != OtherQuals && (MyQuals | OtherQuals) == MyQuals;
}
@ -1969,11 +1968,10 @@ inline bool QualType::isMoreQualifiedThan(QualType Other) const {
/// int" is at least as qualified as "const int", "volatile int",
/// "int", and "const volatile int".
inline bool QualType::isAtLeastAsQualifiedAs(QualType Other) const {
// FIXME: Handle address spaces
unsigned MyQuals = this->getCVRQualifiers();
unsigned OtherQuals = Other.getCVRQualifiers();
assert(this->getAddressSpace() == 0 && "Address space not checked");
assert(Other.getAddressSpace() == 0 && "Address space not checked");
if (getAddressSpace() != Other.getAddressSpace())
return false;
return (MyQuals | OtherQuals) == MyQuals;
}

View File

@ -22,3 +22,11 @@ struct _st {
int x, y;
} s __attribute ((address_space(1))) = {1, 1};
// rdar://6774906
__attribute__((address_space(256))) void * * const base = 0;
void * get_0(void) {
return base[0]; // expected-error {{illegal implicit cast between two pointers with different address spaces}} \
expected-warning {{returning 'void __attribute__((address_space(256)))*' discards qualifiers, expected 'void *'}}
}