OSDN Git Service

In gcc/objc/:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / try-catch-11.m
index 745deca..e08f321 100644 (file)
@@ -1,42 +1,51 @@
-/* Check that throwing an exception from a -forward:: works.  */
-/* Developed by Marcin Koziej <creep@desk.pl>.  */
+/* Ensure that typeof()-typed variables inside the @try { } block that
+   "inherit" their EH-volatileness from other variables in the stack frame
+   do not trigger "discards qualifiers from target pointer type" warnings.  */
 
-/* { dg-do run } */
-/* { dg-options "-fobjc-exceptions -w" } */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
 
-#import <objc/Object.h>
-#import <objc/objc-api.h>
-#include <stdlib.h>
+typedef volatile int IOSharedLockData;
 
-static int i;
-
-@interface Thrower : Object
-- forward: (SEL) s : (void*) a;
+@interface TestMyTests
+- (void) testSpoon;
 @end
 
-@implementation Thrower
-- forward: (SEL) s : (void*) a
-{
-  i++;
-  @throw [Object new];
+extern void some_func (int *);
+
+@implementation TestMyTests
+- (void) testSpoon {
+  int i = 5;
+
+  do {
+    @try {
+      typeof(i) j = 6;
+      some_func (&j);
+    }
+    @catch (id exc) {
+      @throw;
+    }
+  } while(0);
+
+  do {
+    @try {
+      typeof(i) j = 7;
+      some_func (&j);
+    }
+    @catch (id exc) {
+      @throw;
+    }
+  } while(0);
+
+  do {
+    @try {
+      typeof(i) j = 8;
+      some_func (&j);
+    }
+    @catch (id exc) {
+      @throw;
+    }
+  } while(0);
+      
 }
 @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