summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-06-07 17:27:51 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-06-07 17:27:51 +0000
commit3ce7b20590c556f8ecd22a5fae5dbf85188e6bcb (patch)
tree24b2e4a06e24a11b0cc5aa4a7a99def6c94435f1
parent7dbab8a6a19f25c1367efc2c1872d7110e570861 (diff)
downloadbcm5719-llvm-3ce7b20590c556f8ecd22a5fae5dbf85188e6bcb.tar.gz
bcm5719-llvm-3ce7b20590c556f8ecd22a5fae5dbf85188e6bcb.zip
Fix crash with conversion to an address-space-qualified pointer. Bug
reported on cfe-dev by Cédric Venet. Note that I seriously doubt that this perticular construct is useful, though: it's a pointer in an alternate address space pointing into unqualified address space. llvm-svn: 52076
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp4
-rw-r--r--clang/test/CodeGen/address-space-cast.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index f5977728af8..cae1f4bb248 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -632,7 +632,7 @@ public:
// Handle pointer conversions next: pointers can only be converted to/from
// other pointers and integers.
- if (isa<PointerType>(DstType)) {
+ if (isa<llvm::PointerType>(DstTy)) {
// The source value may be an integer, or a pointer.
if (isa<llvm::PointerType>(Src->getType()))
return llvm::ConstantExpr::getBitCast(Src, DstTy);
@@ -640,7 +640,7 @@ public:
return llvm::ConstantExpr::getIntToPtr(Src, DstTy);
}
- if (isa<PointerType>(SrcType)) {
+ if (isa<llvm::PointerType>(Src->getType())) {
// Must be an ptr to int cast.
assert(isa<llvm::IntegerType>(DstTy) && "not ptr->int?");
return llvm::ConstantExpr::getPtrToInt(Src, DstTy);
diff --git a/clang/test/CodeGen/address-space-cast.c b/clang/test/CodeGen/address-space-cast.c
new file mode 100644
index 00000000000..473c8e0e81c
--- /dev/null
+++ b/clang/test/CodeGen/address-space-cast.c
@@ -0,0 +1,4 @@
+// RUN: clang -emit-llvm < %s
+
+volatile unsigned char* const __attribute__((address_space(1))) serial_ctrl = 0x02;
+
OpenPOWER on IntegriCloud