aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/objc.dg')
-rw-r--r--gcc/testsuite/objc.dg/pr101666-0.m7
-rw-r--r--gcc/testsuite/objc.dg/pr101666-1.m10
-rw-r--r--gcc/testsuite/objc.dg/pr101666.inc29
3 files changed, 46 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/pr101666-0.m b/gcc/testsuite/objc.dg/pr101666-0.m
new file mode 100644
index 0000000..5f87f60
--- /dev/null
+++ b/gcc/testsuite/objc.dg/pr101666-0.m
@@ -0,0 +1,7 @@
+/* { dg-do run } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-skip-if "ABI 2 only" { *-*-* && { ! objc2 } } { "*" } { "" } } */
+/* { dg-additional-options "-fobjc-nilcheck -Wno-objc-root-class" } */
+
+#include "pr101666.inc"
+
diff --git a/gcc/testsuite/objc.dg/pr101666-1.m b/gcc/testsuite/objc.dg/pr101666-1.m
new file mode 100644
index 0000000..41ef370
--- /dev/null
+++ b/gcc/testsuite/objc.dg/pr101666-1.m
@@ -0,0 +1,10 @@
+/* Later versions of Darwin can compile for 10.5, but cannot link it so we
+ can only run this test up to 10.13. */
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-do run { target *-*-darwin[89]* *-*-darwin1[0-7]* } } */
+/* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-skip-if "ABI 2 only" { *-*-* && { ! objc2 } } { "*" } { "" } } */
+/* { dg-additional-options "-fobjc-nilcheck -mmacosx-version-min=10.5 " } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
+
+#include "pr101666.inc"
diff --git a/gcc/testsuite/objc.dg/pr101666.inc b/gcc/testsuite/objc.dg/pr101666.inc
new file mode 100644
index 0000000..f1dddca
--- /dev/null
+++ b/gcc/testsuite/objc.dg/pr101666.inc
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+struct point { double x, y, z; };
+
+@interface Foo
+- (struct point)bar;
+- (struct point)baz;
+@end
+
+@implementation Foo
+- (struct point)bar { struct point q = { 1.0, 2.0, 3.0 }; return q; };
+- (struct point)baz { struct point q = { 4.0, 5.0, 6.0 }; return q; };
+@end
+
+/* Cases where a check for nil should be inserted by the compiler, when
+ -fobjc-nilcheck is in force. We should not attempt the calls, and the
+ result should be 0-filled. */
+
+Foo *f;
+
+int main(void) {
+ struct point p = [f bar];
+ if (p.x != 0.0 || p.y != 0.0 || p.z != 0.0)
+ abort ();
+ id nilobj = (id)0;
+ p = [nilobj baz];
+ if (p.x != 0.0 || p.y != 0.0 || p.z != 0.0)
+ abort ();
+ return 0;
+}