exceptions.exp: New exp for the exceptions testsuite.
authorAndrew Pinski <pinskia@gcc.gnu.org>
Sun, 14 Aug 2005 00:58:26 +0000 (17:58 -0700)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sun, 14 Aug 2005 00:58:26 +0000 (17:58 -0700)
* objc/execute/exceptions/exceptions.exp: New exp for the exceptions
testsuite.
* objc/execute/exceptions/trivial.m: New test.
* objc.dg/try-catch-11.m: Move to ...
* objc/execute/exceptions/foward-1.m: Here.
* objc.dg/try-catch-2.m: Move to ...
* objc/execute/exceptions/catchall-1.m: Here.
* objc.dg/try-catch-8.m: Move to ...
* objc/execute/exceptions/local-variables-1.m: Here.

From-SVN: r103071

gcc/testsuite/objc.dg/try-catch-11.m [deleted file]
gcc/testsuite/objc.dg/try-catch-2.m [deleted file]
gcc/testsuite/objc.dg/try-catch-8.m [deleted file]
gcc/testsuite/objc/execute/exceptions/catchall-1.m [new file with mode: 0644]
gcc/testsuite/objc/execute/exceptions/exceptions.exp [new file with mode: 0644]
gcc/testsuite/objc/execute/exceptions/foward-1.m [new file with mode: 0644]
gcc/testsuite/objc/execute/exceptions/local-variables-1.m [new file with mode: 0644]
gcc/testsuite/objc/execute/exceptions/trivial.m [new file with mode: 0644]

diff --git a/gcc/testsuite/objc.dg/try-catch-11.m b/gcc/testsuite/objc.dg/try-catch-11.m
deleted file mode 100644 (file)
index 745deca..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Check that throwing an exception from a -forward:: works.  */
-/* Developed by Marcin Koziej <creep@desk.pl>.  */
-
-/* { dg-do run } */
-/* { dg-options "-fobjc-exceptions -w" } */
-
-#import <objc/Object.h>
-#import <objc/objc-api.h>
-#include <stdlib.h>
-
-static int i;
-
-@interface Thrower : Object
-- forward: (SEL) s : (void*) a;
-@end
-
-@implementation Thrower
-- forward: (SEL) s : (void*) a
-{
-  i++;
-  @throw [Object new];
-}
-@end
-int
-main()
-{
-  id t = [Thrower new];
-  @try
-  {
-    [t doesnotexist];
-  }
-  @catch (id error)
-  {
-    i++;
-    [error free];
-  }
-  
-  if (i != 2)
-    abort ();
-  
-  return 0;
-}
\ No newline at end of file
diff --git a/gcc/testsuite/objc.dg/try-catch-2.m b/gcc/testsuite/objc.dg/try-catch-2.m
deleted file mode 100644 (file)
index 35d60e9..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Test out '@catch(id foo) {...}', which should catch all uncaught
-   exceptions.  */
-/* Developed by Ziemowit Laski <zlaski@apple.com>.  */
-
-/* { dg-options "-fobjc-exceptions" } */
-/* { dg-do run } */
-
-#include <objc/Object.h>
-#include <stdio.h>
-
-/* The following is not required in actual user code; we include it
-   here to check that the compiler generates an internal definition of
-   _setjmp that is consistent with what <setjmp.h> provides.  */
-#include <setjmp.h>
-
-extern void abort(void);
-#define CHECK_IF(expr) if(!(expr)) abort()
-
-@interface Frob: Object
-@end
-
-@implementation Frob: Object
-@end
-
-static Frob* _connection = nil;
-
-//--------------------------------------------------------------------
-
-
-void test (Object* sendPort)
-{
-       int cleanupPorts = 1;
-       Frob* receivePort = nil;
-       
-       @try {
-               printf ("receivePort = %p\n", receivePort);
-               printf ("sendPort = %p\n", sendPort);
-               printf ("cleanupPorts = %d\n", cleanupPorts);
-               printf ("---\n");
-               
-               receivePort = (Frob *) -1;
-               _connection = (Frob *) -1;
-               printf ("receivePort = %p\n", receivePort);
-               printf ("sendPort = %p\n", sendPort);
-               printf ("cleanupPorts = %d\n", cleanupPorts);
-               printf ("---\n");
-               
-               receivePort = nil;
-               sendPort = nil;
-               cleanupPorts = 0;
-               
-               printf ("receivePort = %p\n", receivePort);
-               printf ("sendPort = %p\n", sendPort);
-               printf ("cleanupPorts = %d\n", cleanupPorts);
-               printf ("---\n");               
-               
-               @throw [Object new];
-       }
-       @catch(Frob *obj) {
-               printf ("Exception caught by incorrect handler!\n");
-               CHECK_IF(0);
-       }
-       @catch(id exc) {
-               printf ("Exception caught by correct handler.\n");
-               printf ("receivePort = %p (expected 0x0)\n", receivePort);
-               printf ("sendPort = %p (expected 0x0)\n", sendPort);
-               printf ("cleanupPorts = %d (expected 0)\n", cleanupPorts);
-               printf ("---");
-               CHECK_IF(!receivePort);
-               CHECK_IF(!sendPort);
-               CHECK_IF(!cleanupPorts);
-       }
-}
-
-int main (void) {
-
-       test((Object *)-1);
-       return 0;
-}
diff --git a/gcc/testsuite/objc.dg/try-catch-8.m b/gcc/testsuite/objc.dg/try-catch-8.m
deleted file mode 100644 (file)
index 384faa3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Check that local variables that get modified inside the @try
-   block survive until the @catch block is reached.  */
-/* Developed by Ziemowit Laski <zlaski@apple.com>.  */
-
-/* { dg-options "-fobjc-exceptions -O2" } */
-/* { dg-do run } */
-
-#include <objc/Object.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-int gi1 = 9, gi2 = 19;
-float gf1 = 9.0, gf2 = 19.0;
-id obj2 = nil;
-
-void foo (int arg1, float *arg2)
-{
-  int *pi = &gi1;
-  float *pf = &gf1;
-  id obj1 = nil;
-  int local1 = 45, local2 = 47;
-  float local3 = 3.0, local4 = 4.0;
-  register int local5 = 15;
-  static float local6 = 16.0;
-
-  @try {
-    local1 = 123;
-    local2 = 345;
-    local3 = 5.0;
-    local4 = 6.0;
-    local5 = 17;
-    local6 = 18.0;
-    pi = &gi2;
-    pf = &gf2;
-    obj2 = obj1 = [Object new];
-    arg1 = 17;
-    arg2 = &gf2;
-    
-    @throw [Object new];
-  }
-  @catch (Object *obj) {
-    if (local1 != 123 || local2 != 345 || local3 != 5.0 || local4 != 6.0
-       || local5 != 17 || local6 != 18.0) {
-      printf("Abort 1\n");
-      abort();
-    }
-    if(pi != &gi2 || pf != &gf2) {
-      printf("Abort 2\n");
-      abort();
-    }
-    if(!obj1 || obj1 != obj2) {
-      printf("Abort 3\n");
-      abort();
-    }
-    if(arg1 != 17 || arg2 != &gf2) {
-      printf("Abort 4\n");
-      abort();
-    }
-  }
-}
-
-int main(void) {
-  foo(15, &gf1);
-  return 0;
-}
diff --git a/gcc/testsuite/objc/execute/exceptions/catchall-1.m b/gcc/testsuite/objc/execute/exceptions/catchall-1.m
new file mode 100644 (file)
index 0000000..ac7d127
--- /dev/null
@@ -0,0 +1,76 @@
+/* Test out '@catch(id foo) {...}', which should catch all uncaught
+   exceptions.  */
+/* Developed by Ziemowit Laski <zlaski@apple.com>.  */
+
+#include <objc/Object.h>
+#include <stdio.h>
+
+/* The following is not required in actual user code; we include it
+   here to check that the compiler generates an internal definition of
+   _setjmp that is consistent with what <setjmp.h> provides.  */
+#include <setjmp.h>
+
+extern void abort(void);
+#define CHECK_IF(expr) if(!(expr)) abort()
+
+@interface Frob: Object
+@end
+
+@implementation Frob: Object
+@end
+
+static Frob* _connection = nil;
+
+//--------------------------------------------------------------------
+
+
+void test (Object* sendPort)
+{
+       int cleanupPorts = 1;
+       Frob* receivePort = nil;
+       
+       @try {
+               printf ("receivePort = %p\n", receivePort);
+               printf ("sendPort = %p\n", sendPort);
+               printf ("cleanupPorts = %d\n", cleanupPorts);
+               printf ("---\n");
+               
+               receivePort = (Frob *) -1;
+               _connection = (Frob *) -1;
+               printf ("receivePort = %p\n", receivePort);
+               printf ("sendPort = %p\n", sendPort);
+               printf ("cleanupPorts = %d\n", cleanupPorts);
+               printf ("---\n");
+               
+               receivePort = nil;
+               sendPort = nil;
+               cleanupPorts = 0;
+               
+               printf ("receivePort = %p\n", receivePort);
+               printf ("sendPort = %p\n", sendPort);
+               printf ("cleanupPorts = %d\n", cleanupPorts);
+               printf ("---\n");               
+               
+               @throw [Object new];
+       }
+       @catch(Frob *obj) {
+               printf ("Exception caught by incorrect handler!\n");
+               CHECK_IF(0);
+       }
+       @catch(id exc) {
+               printf ("Exception caught by correct handler.\n");
+               printf ("receivePort = %p (expected 0x0)\n", receivePort);
+               printf ("sendPort = %p (expected 0x0)\n", sendPort);
+               printf ("cleanupPorts = %d (expected 0)\n", cleanupPorts);
+               printf ("---");
+               CHECK_IF(!receivePort);
+               CHECK_IF(!sendPort);
+               CHECK_IF(!cleanupPorts);
+       }
+}
+
+int main (void) {
+
+       test((Object *)-1);
+       return 0;
+}
diff --git a/gcc/testsuite/objc/execute/exceptions/exceptions.exp b/gcc/testsuite/objc/execute/exceptions/exceptions.exp
new file mode 100644 (file)
index 0000000..6c21660
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright (C) 1991, 1992, 1993, 1995, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 
+
+# This file was written by Rob Savoye. (rob@cygnus.com)
+# Modified by Ovidiu Predescu (ovidiu@aracnet.com)
+
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set additional_flags ""
+lappend additional_flags "-fobjc-exceptions"
+
+# load support procs
+load_lib objc-torture.exp
+
+#
+# main test loop
+#
+
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.m]] {
+    # If we're only testing specific files and this isn't one of them, skip it.
+    if ![runtest_file_p $runtests $src] then {
+       continue
+    }
+
+    objc-torture-execute $src $additional_flags
+}
diff --git a/gcc/testsuite/objc/execute/exceptions/foward-1.m b/gcc/testsuite/objc/execute/exceptions/foward-1.m
new file mode 100644 (file)
index 0000000..67fbfcb
--- /dev/null
@@ -0,0 +1,39 @@
+/* Check that throwing an exception from a -forward:: works.  */
+/* Developed by Marcin Koziej <creep@desk.pl>.  */
+
+#import <objc/Object.h>
+#import <objc/objc-api.h>
+#include <stdlib.h>
+
+static int i;
+
+@interface Thrower : Object
+- forward: (SEL) s : (void*) a;
+@end
+
+@implementation Thrower
+- forward: (SEL) s : (void*) a
+{
+  i++;
+  @throw [Object new];
+}
+@end
+int
+main()
+{
+  id t = [Thrower new];
+  @try
+  {
+    [t doesnotexist];
+  }
+  @catch (id error)
+  {
+    i++;
+    [error free];
+  }
+  
+  if (i != 2)
+    abort ();
+  
+  return 0;
+}
diff --git a/gcc/testsuite/objc/execute/exceptions/local-variables-1.m b/gcc/testsuite/objc/execute/exceptions/local-variables-1.m
new file mode 100644 (file)
index 0000000..79a6297
--- /dev/null
@@ -0,0 +1,62 @@
+/* Check that local variables that get modified inside the @try
+   block survive until the @catch block is reached.  */
+/* Developed by Ziemowit Laski <zlaski@apple.com>.  */
+
+#include <objc/Object.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int gi1 = 9, gi2 = 19;
+float gf1 = 9.0, gf2 = 19.0;
+id obj2 = nil;
+
+void foo (int arg1, float *arg2)
+{
+  int *pi = &gi1;
+  float *pf = &gf1;
+  id obj1 = nil;
+  int local1 = 45, local2 = 47;
+  float local3 = 3.0, local4 = 4.0;
+  register int local5 = 15;
+  static float local6 = 16.0;
+
+  @try {
+    local1 = 123;
+    local2 = 345;
+    local3 = 5.0;
+    local4 = 6.0;
+    local5 = 17;
+    local6 = 18.0;
+    pi = &gi2;
+    pf = &gf2;
+    obj2 = obj1 = [Object new];
+    arg1 = 17;
+    arg2 = &gf2;
+    
+    @throw [Object new];
+  }
+  @catch (Object *obj) {
+    if (local1 != 123 || local2 != 345 || local3 != 5.0 || local4 != 6.0
+       || local5 != 17 || local6 != 18.0) {
+      printf("Abort 1\n");
+      abort();
+    }
+    if(pi != &gi2 || pf != &gf2) {
+      printf("Abort 2\n");
+      abort();
+    }
+    if(!obj1 || obj1 != obj2) {
+      printf("Abort 3\n");
+      abort();
+    }
+    if(arg1 != 17 || arg2 != &gf2) {
+      printf("Abort 4\n");
+      abort();
+    }
+  }
+}
+
+int main(void) {
+  foo(15, &gf1);
+  return 0;
+}
diff --git a/gcc/testsuite/objc/execute/exceptions/trivial.m b/gcc/testsuite/objc/execute/exceptions/trivial.m
new file mode 100644 (file)
index 0000000..f1dce2c
--- /dev/null
@@ -0,0 +1,7 @@
+#import <objc/Object.h>
+
+int main(void)
+{
+  [Object class];
+  return 0;
+}