Mercurial > projects > ldc
comparison gen/arrays.cpp @ 1495:0c8d6d345001
The llvm element type of void arrays should be i8 and not void.
This caused DtoArrayCopyToSlice to fail when trying to get the size of
llvm-void for something like void[3] s = "abc"; inside a function.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Fri, 12 Jun 2009 20:39:01 +0200 |
parents | b3ba2c6ff038 |
children | 7a528017b4c6 |
comparison
equal
deleted
inserted
replaced
1494:b243e28f63d4 | 1495:0c8d6d345001 |
---|---|
182 case Tsarray: | 182 case Tsarray: |
183 funcname = "_d_array_init_mem"; | 183 funcname = "_d_array_init_mem"; |
184 assert(arrayelemty == valuety && "ArrayInit doesn't work on elem-initialized static arrays"); | 184 assert(arrayelemty == valuety && "ArrayInit doesn't work on elem-initialized static arrays"); |
185 args[0] = DtoBitCast(args[0], getVoidPtrType()); | 185 args[0] = DtoBitCast(args[0], getVoidPtrType()); |
186 args[2] = DtoBitCast(args[2], getVoidPtrType()); | 186 args[2] = DtoBitCast(args[2], getVoidPtrType()); |
187 args.push_back(DtoConstSize_t(getTypePaddedSize(DtoType(arrayelemty)))); | 187 args.push_back(DtoConstSize_t(getTypePaddedSize(DtoTypeNotVoid(arrayelemty)))); |
188 break; | 188 break; |
189 | 189 |
190 default: | 190 default: |
191 error("unhandled array init: %s = %s", array->getType()->toChars(), value->getType()->toChars()); | 191 error("unhandled array init: %s = %s", array->getType()->toChars(), value->getType()->toChars()); |
192 assert(0 && "unhandled array init"); | 192 assert(0 && "unhandled array init"); |
245 fatal(); | 245 fatal(); |
246 } | 246 } |
247 | 247 |
248 // get elem type | 248 // get elem type |
249 Type* elemty = arrty->nextOf(); | 249 Type* elemty = arrty->nextOf(); |
250 const LLType* llelemty = DtoType(elemty); | 250 const LLType* llelemty = DtoTypeNotVoid(elemty); |
251 | 251 |
252 // true if array elements differ in type, can happen with array of unions | 252 // true if array elements differ in type, can happen with array of unions |
253 bool mismatch = false; | 253 bool mismatch = false; |
254 | 254 |
255 // allocate room for initializers | 255 // allocate room for initializers |
365 | 365 |
366 LLValue* sz1; | 366 LLValue* sz1; |
367 LLValue* dstarr = get_slice_ptr(dst,sz1); | 367 LLValue* dstarr = get_slice_ptr(dst,sz1); |
368 | 368 |
369 LLValue* srcarr = DtoBitCast(DtoArrayPtr(src), getVoidPtrType()); | 369 LLValue* srcarr = DtoBitCast(DtoArrayPtr(src), getVoidPtrType()); |
370 const LLType* arrayelemty = DtoType(src->getType()->nextOf()->toBasetype()); | 370 const LLType* arrayelemty = DtoTypeNotVoid(src->getType()->nextOf()->toBasetype()); |
371 LLValue* sz2 = gIR->ir->CreateMul(DtoConstSize_t(getTypePaddedSize(arrayelemty)), DtoArrayLen(src), "tmp"); | 371 LLValue* sz2 = gIR->ir->CreateMul(DtoConstSize_t(getTypePaddedSize(arrayelemty)), DtoArrayLen(src), "tmp"); |
372 | 372 |
373 if (global.params.useAssert || global.params.useArrayBounds) | 373 if (global.params.useAssert || global.params.useArrayBounds) |
374 { | 374 { |
375 LLValue* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_slice_copy"); | 375 LLValue* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_slice_copy"); |