summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-29 03:15:40 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-29 03:15:40 +0000
commitb3d2d31213e2b3d34a5ae67b01c667a23e25afa4 (patch)
tree44406a903b8b5e0d042b1c9cd87592f05480f94d /gcc/testsuite
parenteab1044ee50db420e5090a3249b6ce873f39dc47 (diff)
downloadgcc-b3d2d31213e2b3d34a5ae67b01c667a23e25afa4.tar.gz
In gcc/objc/:
2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com> * objc-act.c (objc_eh_runtime_type): Avoid ICE if error_mark_node is passed as argument. (objc_begin_catch_clause): Added code to deal with an error_mark_node or NULL_TREE argument. Improved checks for invalid arguments. Added code to traverse typedefs. In gcc/testsuite/: 2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com> * objc.dg/exceptions-1.m: New. * objc.dg/exceptions-2.m: New. * objc.dg/exceptions-3.m: New. * objc.dg/exceptions-4.m: New. * objc.dg/exceptions-5.m: New. * obj-c++.dg/exceptions-1.mm: New. * obj-c++.dg/exceptions-2.mm: New. * obj-c++.dg/exceptions-3.mm: New. * obj-c++.dg/exceptions-4.mm: New. * obj-c++.dg/exceptions-5.mm: New. In gcc/cp/: 2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com> * parser.c (cp_parser_objc_try_catch_finally_statement): Parse @catch(...) and pass NULL_TREE to objc_begin_catch_clause() in that case. Improved error recovery. Reorganized code to be almost identical to c_parser_objc_try_catch_finally_statement. In gcc/: 2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com> * c-parser.c (c_parser_objc_try_catch_statement): Renamed to c_parser_objc_try_catch_finally_statement for consistency with the C++ parser. Parse @catch(...) and pass NULL_TREE to objc_begin_catch_clause() in that case. Improved error recovery. Reorganized code to be almost identical to cp_parser_objc_try_catch_finally_statement. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167233 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog13
-rw-r--r--gcc/testsuite/obj-c++.dg/exceptions-1.mm42
-rw-r--r--gcc/testsuite/obj-c++.dg/exceptions-2.mm54
-rw-r--r--gcc/testsuite/obj-c++.dg/exceptions-3.mm114
-rw-r--r--gcc/testsuite/obj-c++.dg/exceptions-4.mm64
-rw-r--r--gcc/testsuite/obj-c++.dg/exceptions-5.mm114
-rw-r--r--gcc/testsuite/objc.dg/exceptions-1.m42
-rw-r--r--gcc/testsuite/objc.dg/exceptions-2.m52
-rw-r--r--gcc/testsuite/objc.dg/exceptions-3.m114
-rw-r--r--gcc/testsuite/objc.dg/exceptions-4.m64
-rw-r--r--gcc/testsuite/objc.dg/exceptions-5.m114
11 files changed, 787 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c7830ebc2b9..6185f595b4d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,18 @@
2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com>
+ * objc.dg/exceptions-1.m: New.
+ * objc.dg/exceptions-2.m: New.
+ * objc.dg/exceptions-3.m: New.
+ * objc.dg/exceptions-4.m: New.
+ * objc.dg/exceptions-5.m: New.
+ * obj-c++.dg/exceptions-1.mm: New.
+ * obj-c++.dg/exceptions-2.mm: New.
+ * obj-c++.dg/exceptions-3.mm: New.
+ * obj-c++.dg/exceptions-4.mm: New.
+ * obj-c++.dg/exceptions-5.mm: New.
+
+2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com>
+
* obj-c++.dg/property/at-property-1.mm: Fixed testcase.
* obj-c++.dg/property/at-property-16.mm: Fixed testcase.
* obj-c++.dg/property/at-property-20.mm: Fixed testcase.
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-1.mm b/gcc/testsuite/obj-c++.dg/exceptions-1.mm
new file mode 100644
index 00000000000..0f3b7e8ae14
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/exceptions-1.mm
@@ -0,0 +1,42 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* This test checks the syntax @catch (...) which catches any
+ exceptions. At the moment, @catch (...) is identical to @catch (id
+ exception). */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+int test (id object)
+{
+ int i = 0;
+
+ @try
+ {
+ @throw object;
+ }
+ @catch (MyObject *o)
+ {
+ i += 1;
+ }
+ @catch (...)
+ {
+ i += 2;
+ }
+ @finally
+ {
+ i += 4;
+ }
+
+ return i;
+}
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-2.mm b/gcc/testsuite/obj-c++.dg/exceptions-2.mm
new file mode 100644
index 00000000000..ce85b731325
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/exceptions-2.mm
@@ -0,0 +1,54 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+
+/* FIXME: This does not test running the code, because Objective-C exceptions at the moment
+ do not execute correctly in Objective-C++. See PR objc++/23616. Once that is fixed,
+ this test should be changed to use 'dg-run' instead of just 'dg-compile'. */
+/* { dg-compile } */
+
+/* This test checks the syntax @catch (...) which catches any
+ exceptions. Check that code using it runs correctly. */
+
+#include "../objc-obj-c++-shared/Object1.h"
+#include <stdlib.h>
+
+@interface MyObject : Object
+@end
+
+@implementation MyObject
+@end
+
+int test (id object)
+{
+ int i = 0;
+
+ @try
+ {
+ @throw object;
+ }
+ @catch (MyObject *o)
+ {
+ i += 1;
+ }
+ @catch (...)
+ {
+ i += 2;
+ }
+ @finally
+ {
+ i += 4;
+ }
+
+ return i;
+}
+
+int main (void)
+{
+ if (test ([MyObject new]) != 5)
+ abort ();
+
+ if (test ([Object new]) != 6)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-3.mm b/gcc/testsuite/obj-c++.dg/exceptions-3.mm
new file mode 100644
index 00000000000..b1ba1852725
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/exceptions-3.mm
@@ -0,0 +1,114 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test that the compiler is checking the argument of @catch(), and
+ produce errors when invalid types are used. */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+@protocol MyProtocol;
+
+typedef MyObject MyObjectTypedef;
+typedef MyObject *MyObjectPtrTypedef;
+typedef int intTypedef;
+
+int test (id object)
+{
+ int dummy = 0;
+
+ @try { @throw object; }
+ @catch (int x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (intTypedef x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (int *x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id <MyProtocol> x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject *x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ { /* { dg-error "no matching function" "" { target *-*-* } 72 } */
+ dummy++; /* { dg-warning "MyObject" "" { target *-*-* } 13 } */
+ }
+
+ @try { @throw object; }
+ @catch (static MyObject *x) /* { dg-error "storage class" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef *x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectPtrTypedef x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (Class x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (...) /* Ok */
+ {
+ dummy++;
+ }
+
+ return dummy;
+}
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-4.mm b/gcc/testsuite/obj-c++.dg/exceptions-4.mm
new file mode 100644
index 00000000000..85debe444b6
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/exceptions-4.mm
@@ -0,0 +1,64 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test warnings when parsing syntax errors in @catch(). */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+@interface MyObject2
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject2
+@end
+
+@protocol MyProtocol;
+
+int test (id object)
+{
+ int dummy = 0;
+
+ @try { @throw object; }
+ @catch
+ { /* { dg-error "expected" } */
+ dummy++; /* { dg-error "@catch parameter is not a known Objective-C class type" "" { target *-*-* } 35 } */
+ }
+ @catch () /* { dg-error "expected identifier before" } */
+ { /* { dg-error "@catch parameter is not a known Objective-C class type" "" { target *-*-* } 38 } */
+ dummy++;
+ }
+ @catch (i) /* { dg-error ".i. has not been declared" } */
+ { /* { dg-error "@catch parameter is not a known Objective-C class type" "" { target *-*-* } 42 } */
+ dummy++;
+ }
+ @catch (id <MyProtocol x) /* { dg-error "expected ... before .x." } */
+ { /* { dg-error "@catch parameter can not be protocol-qualified" "" { target *-*-* } 46 } */
+ dummy++;
+ }
+ @catch MyObject *x /* { dg-error "expected ... before .MyObject." } */
+ {
+ dummy++;
+ }
+ @catch MyObject2 *x) /* { dg-error "expected ... before .MyObject2." } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject *x)
+ @catch (MyObject2 *y) /* { dg-error "expected ... before .catch." } */
+
+ return dummy; /* { dg-error "expected ... before .return." } */
+}
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-5.mm b/gcc/testsuite/obj-c++.dg/exceptions-5.mm
new file mode 100644
index 00000000000..f7404968844
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/exceptions-5.mm
@@ -0,0 +1,114 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test that you can use an unnamed argument with @catch. This test is the same
+ as exceptions-3.mm, but with no name for @catch arguments. */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+@protocol MyProtocol;
+
+typedef MyObject MyObjectTypedef;
+typedef MyObject *MyObjectPtrTypedef;
+typedef int intTypedef;
+
+int test (id object)
+{
+ int dummy = 0;
+
+ @try { @throw object; }
+ @catch (int) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (intTypedef) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (int *) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id <MyProtocol>) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject *) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject <MyProtocol> *) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ { /* { dg-error "no matching function" "" { target *-*-* } 72 } */
+ dummy++; /* { dg-warning "MyObject" "" { target *-*-* } 13 } */
+ }
+
+ @try { @throw object; }
+ @catch (static MyObject *) /* { dg-error "storage class" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef *) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef <MyProtocol> *) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectPtrTypedef) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (Class) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (...) /* Ok */
+ {
+ dummy++;
+ }
+
+ return dummy;
+}
diff --git a/gcc/testsuite/objc.dg/exceptions-1.m b/gcc/testsuite/objc.dg/exceptions-1.m
new file mode 100644
index 00000000000..0f3b7e8ae14
--- /dev/null
+++ b/gcc/testsuite/objc.dg/exceptions-1.m
@@ -0,0 +1,42 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* This test checks the syntax @catch (...) which catches any
+ exceptions. At the moment, @catch (...) is identical to @catch (id
+ exception). */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+int test (id object)
+{
+ int i = 0;
+
+ @try
+ {
+ @throw object;
+ }
+ @catch (MyObject *o)
+ {
+ i += 1;
+ }
+ @catch (...)
+ {
+ i += 2;
+ }
+ @finally
+ {
+ i += 4;
+ }
+
+ return i;
+}
diff --git a/gcc/testsuite/objc.dg/exceptions-2.m b/gcc/testsuite/objc.dg/exceptions-2.m
new file mode 100644
index 00000000000..3e4227cb965
--- /dev/null
+++ b/gcc/testsuite/objc.dg/exceptions-2.m
@@ -0,0 +1,52 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-do run } */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-sources "../objc-obj-c++-shared/Object1.m" } */
+
+/* This test checks the syntax @catch (...) which catches any
+ exceptions. Check that code using it runs correctly. */
+
+#include "../objc-obj-c++-shared/Object1.h"
+#include <stdlib.h>
+
+@interface MyObject : Object
+@end
+
+@implementation MyObject
+@end
+
+int test (id object)
+{
+ int i = 0;
+
+ @try
+ {
+ @throw object;
+ }
+ @catch (MyObject *o)
+ {
+ i += 1;
+ }
+ @catch (...)
+ {
+ i += 2;
+ }
+ @finally
+ {
+ i += 4;
+ }
+
+ return i;
+}
+
+int main (void)
+{
+ if (test ([MyObject new]) != 5)
+ abort ();
+
+ if (test ([Object new]) != 6)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc.dg/exceptions-3.m b/gcc/testsuite/objc.dg/exceptions-3.m
new file mode 100644
index 00000000000..fe9dbfbfa06
--- /dev/null
+++ b/gcc/testsuite/objc.dg/exceptions-3.m
@@ -0,0 +1,114 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test that the compiler is checking the argument of @catch(), and
+ produce errors when invalid types are used. */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+@protocol MyProtocol;
+
+typedef MyObject MyObjectTypedef;
+typedef MyObject *MyObjectPtrTypedef;
+typedef int intTypedef;
+
+int test (id object)
+{
+ int dummy = 0;
+
+ @try { @throw object; }
+ @catch (int x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (intTypedef x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (int *x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id <MyProtocol> x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject *x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ { /* { dg-error "conversion to non-scalar type requested" "" { target *-*-* } 72 } */
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (static MyObject *x) /* { dg-error "storage class specified for" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef *x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectPtrTypedef x) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (Class x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (...) /* Ok */
+ {
+ dummy++;
+ }
+
+ return dummy;
+}
diff --git a/gcc/testsuite/objc.dg/exceptions-4.m b/gcc/testsuite/objc.dg/exceptions-4.m
new file mode 100644
index 00000000000..a8a26ecebb2
--- /dev/null
+++ b/gcc/testsuite/objc.dg/exceptions-4.m
@@ -0,0 +1,64 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test warnings when parsing syntax errors in @catch(). */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+@interface MyObject2
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject2
+@end
+
+@protocol MyProtocol;
+
+int test (id object)
+{
+ int dummy = 0;
+
+ @try { @throw object; }
+ @catch
+ { /* { dg-error "expected ... before ... token" } */
+ dummy++;
+ }
+ @catch () /* { dg-error "expected declaration specifiers or ..... before ..." } */
+ {
+ dummy++;
+ }
+ @catch (i) /* { dg-error "expected declaration specifiers or ..... before .i." } */
+ {
+ dummy++;
+ }
+ @catch (id <MyProtocol x) /* { dg-error "expected ... before .x." } */
+ { /* { dg-error "@catch parameter can not be protocol-qualified" "" { target *-*-* } 46 } */
+ dummy++;
+ }
+ @catch MyObject *x /* { dg-error "expected ... before .MyObject." } */
+ {
+ dummy++;
+ }
+ @catch MyObject2 *x) /* { dg-error "expected ... before .MyObject2." } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject *x)
+ @catch (MyObject2 *y) /* { dg-error "expected ... before .catch." } */
+
+ return dummy;
+}
diff --git a/gcc/testsuite/objc.dg/exceptions-5.m b/gcc/testsuite/objc.dg/exceptions-5.m
new file mode 100644
index 00000000000..d89ad2967c0
--- /dev/null
+++ b/gcc/testsuite/objc.dg/exceptions-5.m
@@ -0,0 +1,114 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test that you can use an unnamed argument with @catch. This test is the same
+ as exceptions-3.m, but with no name for @catch arguments. */
+
+#include <objc/objc.h>
+
+@interface MyObject
+{
+ Class isa;
+}
+@end
+
+@implementation MyObject
+@end
+
+@protocol MyProtocol;
+
+typedef MyObject MyObjectTypedef;
+typedef MyObject *MyObjectPtrTypedef;
+typedef int intTypedef;
+
+int test (id object)
+{
+ int dummy = 0;
+
+ @try { @throw object; }
+ @catch (int) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (intTypedef) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (int *) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (id <MyProtocol>) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject *) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject <MyProtocol> *) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObject) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ { /* { dg-error "conversion to non-scalar type requested" "" { target *-*-* } 72 } */
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (static MyObject *) /* { dg-error "storage class specified for" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef *) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectTypedef <MyProtocol> *) /* { dg-error "@catch parameter can not be protocol-qualified" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (MyObjectPtrTypedef) /* Ok */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (Class) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
+ {
+ dummy++;
+ }
+
+ @try { @throw object; }
+ @catch (...) /* Ok */
+ {
+ dummy++;
+ }
+
+ return dummy;
+}