aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-13 06:04:39 +0000
committerChris Lattner <sabre@nondot.org>2009-04-13 06:04:39 +0000
commitecca7536488e425417dcb005c39cc15ae1947aab (patch)
tree832a179449ad15808bbb0cc1770ec61c8b51383b
parent7486af8fc2c10e2883687d0494b18e092e4b9d1a (diff)
fix rdar://6774906, a crash handling implicit conversions between pointers
in different address spaces. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68941 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Type.h10
-rw-r--r--test/Sema/address_spaces.c8
2 files changed, 12 insertions, 6 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 514c69e72c..62750087c0 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -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;
}
diff --git a/test/Sema/address_spaces.c b/test/Sema/address_spaces.c
index 8f637268a4..b79799f023 100644
--- a/test/Sema/address_spaces.c
+++ b/test/Sema/address_spaces.c
@@ -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 *'}}
+}
+