diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-04-13 06:04:39 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-04-13 06:04:39 +0000 |
| commit | 5c6160d01993587cd016bf3f4d373810285e8af6 (patch) | |
| tree | 3f0cd56a20419542f01e5b8d7d888c36584606c1 | |
| parent | 184f1be4a8029b82df942c351e0aa506b85fe305 (diff) | |
| download | bcm5719-llvm-5c6160d01993587cd016bf3f4d373810285e8af6.tar.gz bcm5719-llvm-5c6160d01993587cd016bf3f4d373810285e8af6.zip | |
fix rdar://6774906, a crash handling implicit conversions between pointers
in different address spaces.
llvm-svn: 68941
| -rw-r--r-- | clang/include/clang/AST/Type.h | 10 | ||||
| -rw-r--r-- | clang/test/Sema/address_spaces.c | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 514c69e72c3..62750087c06 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/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/clang/test/Sema/address_spaces.c b/clang/test/Sema/address_spaces.c index 8f637268a4e..b79799f0230 100644 --- a/clang/test/Sema/address_spaces.c +++ b/clang/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 *'}} +} + |

