Debian Codegraph @

gcc/testsuite/obj-c++.dg/pr101666.inc

raw
1 #include <cstdlib>
2 struct point { double x, y, z; };
3
4 @interface Foo
5 - (struct point)bar;
6 - (struct point)baz;
7 @end
8
9 @implementation Foo
10 - (struct point)bar { struct point q = { 1.0, 2.0, 3.0 }; return q; };
11 - (struct point)baz { struct point q = { 4.0, 5.0, 6.0 }; return q; };
12 @end
13
14 /* Cases where a check for nil should be inserted by the compiler, when
15 -fobjc-nilcheck is in force. We should not attempt the calls, and the
16 result should be 0-filled. */
17
18 Foo *f;
19
20 int main(void) {
21 struct point p = [f bar];
22 if (p.x != 0.0 || p.y != 0.0 || p.z != 0.0)
23 abort ();
24 id nilobj = (id)0;
25 p = [nilobj baz];
26 if (p.x != 0.0 || p.y != 0.0 || p.z != 0.0)
27 abort ();
28 return 0;
29 }