Mercurial > projects > ldc
annotate tests/mini/ptrarith.d @ 1605:1d5721f9ae18
[WIP] Merge DMD r251: bugzilla 111 (appending a dchar to a char[])
This patch needs some work in the code generation, because of the runtime
changes (functions "_d_arrayappendcd" and "_d_arrayappendwd" are added).
This doesn't affect existing code though, it just makes with patch
a little useless, because something like this:
char [] s;
s ~= '\u6211';
That failed to compile with a nice error message previously to this
change, now fails with and ugly error message (a failed assertion).
Apparently there is a regression introduced by this patch too, when
compiling Dil I get this assertion message:
ldc: /home/luca/tesis/ldc/gen/statements.cpp:132: virtual void ReturnStatement::toIR(IRState*): Assertion `p->topfunc()->getReturnType() == llvm::Type::getVoidTy(gIR->context())' failed.
0 ldc 0x08a91628
Thank god we have bisecting capabilities in VCSs now ;)
---
dmd/expression.c | 47 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 41 insertions(+), 6 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:19 -0300 |
parents | 1bb99290e03a |
children |
rev | line source |
---|---|
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
1 extern(C) int printf(char*, ...); |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
2 |
1 | 3 void main() |
4 { | |
5 printf("Pointer arithmetic test\n"); | |
6 int* p; | |
7 printf("0x%x\n", p); | |
8 assert(p++ is null); | |
9 assert(cast(size_t)p == 4); | |
10 printf("0x%x\n", p); | |
11 p--; | |
12 assert(p is null); | |
13 printf("0x%x\n", p); | |
14 int d = 4; | |
15 p+=d; | |
16 printf("0x%x\n", p); | |
17 assert(cast(size_t)p == 16); | |
18 d = 2; | |
19 p+=d; | |
20 printf("0x%x\n", p); | |
21 assert(cast(size_t)p == 0x18); | |
22 d = 6; | |
23 p-=d; | |
24 printf("0x%x\n", p); | |
25 assert(p is null); | |
26 printf(" SUCCESS\n"); | |
27 } | |
28 | |
29 void fill_byte_array(ubyte* a, size_t n, ubyte v) | |
30 { | |
31 auto p = a; | |
32 auto end = a+n; | |
33 while (p !is end) | |
34 *p++ = v; | |
35 } |