]> granicus.if.org Git - clang/commitdiff
Fix crash with conversion to an address-space-qualified pointer. Bug
authorEli Friedman <eli.friedman@gmail.com>
Sat, 7 Jun 2008 17:27:51 +0000 (17:27 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 7 Jun 2008 17:27:51 +0000 (17:27 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52076 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprConstant.cpp
test/CodeGen/address-space-cast.c [new file with mode: 0644]

index f5977728af8dd697a28a0a12f88465c8eb75da9a..cae1f4bb248689c34daecf93a8d1b57d010e3b1b 100644 (file)
@@ -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/test/CodeGen/address-space-cast.c b/test/CodeGen/address-space-cast.c
new file mode 100644 (file)
index 0000000..473c8e0
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: clang -emit-llvm < %s
+
+volatile unsigned char* const __attribute__((address_space(1))) serial_ctrl = 0x02;
+