xref: /llvm-project/clang/test/CodeGenObjC/property-complex.m (revision 7d644e1215b376ec5e915df9ea2eeb56e2d94626)
1// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
2// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
3
4int printf(const char *, ...);
5
6@interface I0 {
7@public
8  _Complex float iv0;
9}
10
11@property(assign) _Complex float p0;
12
13-(_Complex float) im0;
14-(void) setIm0: (_Complex float) a0;
15@end
16
17@implementation I0
18@dynamic p0;
19
20-(id) init {
21  self->iv0 = 5.0 + 2.0i;
22  return self;
23}
24
25-(_Complex float) im0 {
26  printf("im0: %.2f + %.2fi\n", __real iv0, __imag iv0);
27  return iv0 + (.1 + .2i);
28}
29-(void) setIm0: (_Complex float) a0 {
30  printf("setIm0: %.2f + %.2fi\n", __real a0, __imag a0);
31  iv0 = a0 + (.3 + .4i);
32}
33
34-(_Complex float) p0 {
35  printf("p0: %.2f + %.2fi\n", __real iv0, __imag iv0);
36  return iv0 + (.5 + .6i);
37}
38-(void) setP0: (_Complex float) a0 {
39  printf("setP0: %.2f + %.2fi\n", __real a0, __imag a0);
40  iv0 = a0 + (.7 + .8i);
41}
42@end
43
44void f0(I0 *a0) {
45    float l0 = __real a0.im0;
46    float l1 = __imag a0->iv0;
47    _Complex float l2 = (a0.im0 = a0.im0);
48    _Complex float l3 = a0->iv0;
49    _Complex float l4 = (a0->iv0 = a0->iv0);
50    _Complex float l5 = a0->iv0;
51    _Complex float l6 = (a0.p0 = a0.p0);
52    _Complex float l7 = a0->iv0;
53    _Complex float l8 = [a0 im0];
54    printf("l0: %.2f + %.2fi\n", __real l0, __imag l0);
55    printf("l1: %.2f + %.2fi\n", __real l1, __imag l1);
56    printf("l2: %.2f + %.2fi\n", __real l2, __imag l2);
57    printf("l3: %.2f + %.2fi\n", __real l3, __imag l3);
58    printf("l4: %.2f + %.2fi\n", __real l4, __imag l4);
59    printf("l5: %.2f + %.2fi\n", __real l5, __imag l5);
60    printf("l6: %.2f + %.2fi\n", __real l6, __imag l6);
61    printf("l7: %.2f + %.2fi\n", __real l7, __imag l7);
62    printf("l8: %.2f + %.2fi\n", __real l8, __imag l8);
63}
64