[cfe-commits] r52076 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/address-space-cast.c
Eli Friedman
eli.friedman at gmail.com
Sat Jun 7 10:27:51 PDT 2008
Author: efriedma
Date: Sat Jun 7 12:27:51 2008
New Revision: 52076
URL: http://llvm.org/viewvc/llvm-project?rev=52076&view=rev
Log:
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.
Added:
cfe/trunk/test/CodeGen/address-space-cast.c
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=52076&r1=52075&r2=52076&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sat Jun 7 12:27:51 2008
@@ -632,7 +632,7 @@
// 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 @@
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);
Added: cfe/trunk/test/CodeGen/address-space-cast.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/address-space-cast.c?rev=52076&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/address-space-cast.c (added)
+++ cfe/trunk/test/CodeGen/address-space-cast.c Sat Jun 7 12:27:51 2008
@@ -0,0 +1,4 @@
+// RUN: clang -emit-llvm < %s
+
+volatile unsigned char* const __attribute__((address_space(1))) serial_ctrl = 0x02;
+
More information about the cfe-commits
mailing list