[cfe-commits] r68941 - in /cfe/trunk: include/clang/AST/Type.h test/Sema/address_spaces.c
Chris Lattner
sabre at nondot.org
Sun Apr 12 23:04:40 PDT 2009
Author: lattner
Date: Mon Apr 13 01:04:39 2009
New Revision: 68941
URL: http://llvm.org/viewvc/llvm-project?rev=68941&view=rev
Log:
fix rdar://6774906, a crash handling implicit conversions between pointers
in different address spaces.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/test/Sema/address_spaces.c
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=68941&r1=68940&r2=68941&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr 13 01:04:39 2009
@@ -1956,11 +1956,10 @@
/// "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 @@
/// 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;
}
Modified: cfe/trunk/test/Sema/address_spaces.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=68941&r1=68940&r2=68941&view=diff
==============================================================================
--- cfe/trunk/test/Sema/address_spaces.c (original)
+++ cfe/trunk/test/Sema/address_spaces.c Mon Apr 13 01:04:39 2009
@@ -22,3 +22,11 @@
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 *'}}
+}
+
More information about the cfe-commits
mailing list