diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/CodeGenObjC/dot-syntax.m | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/CodeGenObjC/dot-syntax.m')
-rw-r--r-- | clang/test/CodeGenObjC/dot-syntax.m | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjC/dot-syntax.m b/clang/test/CodeGenObjC/dot-syntax.m new file mode 100644 index 0000000..6282ea4 --- /dev/null +++ b/clang/test/CodeGenObjC/dot-syntax.m @@ -0,0 +1,98 @@ +// RUN: %clang_cc1 -emit-llvm -o %t %s + +int printf(const char *, ...); + +@interface Root +-(id) alloc; +-(id) init; +@end + +typedef struct { + float x, y, z[2]; +} S; + +@interface A : Root { + int myX; + // __complex myY; + S myZ; +} + +@property int x; +//@property __complex int y; +@property S z; +@end + +@implementation A +-(int) x { + printf("-[A x] = %d\n", myX); + return myX; +} +-(void) setX: (int) arg { + myX = arg; + printf("-[A setX: %d]\n", myX); +} + +// FIXME: Add back +#if 0 +-(__complex int) y { + printf("-[A y] = (%d, %d)\n", __real myY, __imag myY); + return myY; +} +-(void) setY: (__complex int) arg { + myY = arg; + printf("-[A setY: (%d, %d)]\n", __real myY, __imag myY); +} +#endif + +-(S) z { + printf("-[A z] = { %f, %f, { %f, %f } }\n", + myZ.x, myZ.y, myZ.z[0], myZ.z[1]); + return myZ; +} +-(void) setZ: (S) arg { + myZ = arg; + printf("-[A setZ: { %f, %f, { %f, %f } } ]\n", + myZ.x, myZ.y, myZ.z[0], myZ.z[1]); +} + +@end + +int main() { +#define SWAP(T,a,b) { T a_tmp = a; a = b; b = a_tmp; } + A *a = [[A alloc] init]; + A *b = [[A alloc] init]; + int a0 = 23; + // __complex a1 = 25 + 10i; + S a2 = { 246, 458, {275, 12} }; + int b0 = 42673; + // __complex b1 = 15 + 13i; + S b2 = { 26, 2, {367, 13} }; + + a.x = a0; + // a.y = a1; + a.z = a2; + + a.x += a0; + // a.y += a1; + // Yay, no compound assign of structures. A GCC extension in the + // works, perhaps? + + b.x = b0; + // b.y = b1; + b.z = b2; + + int x0 = (b.x = b0); + printf("(b.x = b0): %d\n", x0); + + // int x1 = __real (b.y = b1); + // printf("__real (b.y = b1) = %d\n", x1); + + float x2 = (b.z = b2).x; + printf("(b.z = b2).x: %f\n", x2); + + SWAP(int, a.x, b.x); + // SWAP(__complex int, a.y, b.y); + SWAP(S, a.z, b.z); + + return 0; +} |