Mercurial > projects > ldc
annotate test/ptrarith.d @ 94:61615fa85940 trunk
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
Added support for array .sort and .reverse properties.
Fixed some bugs with pointer arithmetic.
Disabled some DMD AST optimizations that was messing things up, destroying valuable information.
Added a KDevelop project file, this is what I use for coding LLVMDC now :)
Other minor stuff.
author | lindquist |
---|---|
date | Mon, 12 Nov 2007 06:32:46 +0100 |
parents | c53b6e3fe49a |
children | d9d5d59873d8 |
rev | line source |
---|---|
1 | 1 void main() |
2 { | |
3 printf("Pointer arithmetic test\n"); | |
4 int* p; | |
5 printf("0x%x\n", p); | |
6 assert(p++ is null); | |
7 assert(cast(size_t)p == 4); | |
8 printf("0x%x\n", p); | |
9 p--; | |
10 assert(p is null); | |
11 printf("0x%x\n", p); | |
12 int d = 4; | |
13 p+=d; | |
14 printf("0x%x\n", p); | |
15 assert(cast(size_t)p == 16); | |
16 d = 2; | |
17 p+=d; | |
18 printf("0x%x\n", p); | |
19 assert(cast(size_t)p == 0x18); | |
20 d = 6; | |
21 p-=d; | |
22 printf("0x%x\n", p); | |
23 assert(p is null); | |
24 printf(" SUCCESS\n"); | |
25 } | |
26 | |
27 void fill_byte_array(ubyte* a, size_t n, ubyte v) | |
28 { | |
29 auto p = a; | |
30 auto end = a+n; | |
31 while (p !is end) | |
32 *p++ = v; | |
33 } |