In gcc/objc/: 2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/: 2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com> * objc-act.c (objc_build_throw_stmt): Check that the argument of @throw is an object and emit an error if not. In gcc/testsuite/: 2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com> * objc.dg/exceptions-7.m: New. * obj-c++.dg/exceptions-7.mm: New. * obj-c++.dg/exceptions-3.mm: Adjust for new C++ messages. * obj-c++.dg/exceptions-5.mm: Same change. From-SVN: r167615
This commit is contained in:
parent
e493bdc219
commit
6347cf3119
7 changed files with 60 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* objc-act.c (objc_build_throw_stmt): Check that the argument of
|
||||
@throw is an object and emit an error if not.
|
||||
|
||||
2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* objc-act.c (objc_finish_foreach_loop): Use error_at() instead of
|
||||
|
|
|
@ -5528,6 +5528,14 @@ objc_build_throw_stmt (location_t loc, tree throw_expr)
|
|||
value that we get from the runtime. */
|
||||
throw_expr = objc_build_exc_ptr ();
|
||||
}
|
||||
else if (throw_expr != error_mark_node)
|
||||
{
|
||||
if (!objc_type_valid_for_messaging (TREE_TYPE (throw_expr), true))
|
||||
{
|
||||
error_at (loc, "%<@throw%> argument is not an object");
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
|
||||
/* A throw is just a call to the runtime throw function with the
|
||||
object as a parameter. */
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* objc.dg/exceptions-7.m: New.
|
||||
* obj-c++.dg/exceptions-7.mm: New.
|
||||
* obj-c++.dg/exceptions-3.mm: Adjust for new C++ messages.
|
||||
* obj-c++.dg/exceptions-5.mm: Same change.
|
||||
|
||||
2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* objc.dg/foreach-6.m: Updated location of error messages.
|
||||
|
|
|
@ -72,8 +72,8 @@ int test (id 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 } */
|
||||
}
|
||||
|
||||
} /* { dg-warning "candidate" "" { target *-*-* } 13 } */
|
||||
/* { dg-warning "candidate" "" { target *-*-* } 72 } */
|
||||
@try { @throw object; }
|
||||
@catch (static MyObject *x) /* { dg-error "storage class" } */
|
||||
{
|
||||
|
|
|
@ -72,7 +72,8 @@ int test (id 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 } */
|
||||
}
|
||||
} /* { dg-warning "candidate" "" { target *-*-* } 13 } */
|
||||
/* { dg-warning "candidate" "" { target *-*-* } 72 } */
|
||||
|
||||
@try { @throw object; }
|
||||
@catch (static MyObject *) /* { dg-error "storage class" } */
|
||||
|
|
18
gcc/testsuite/obj-c++.dg/exceptions-7.mm
Normal file
18
gcc/testsuite/obj-c++.dg/exceptions-7.mm
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
|
||||
/* { dg-options "-fobjc-exceptions" } */
|
||||
/* { dg-do compile } */
|
||||
|
||||
/* Test warnings when the argument of @throw is invalid. */
|
||||
|
||||
#include <objc/objc.h>
|
||||
|
||||
void test (id object)
|
||||
{
|
||||
struct x { int i; } invalid_1, *invalid_2;
|
||||
|
||||
@throw object; /* Ok */
|
||||
@throw 1; /* { dg-error ".@throw. argument is not an object" } */
|
||||
@throw "string"; /* { dg-error ".@throw. argument is not an object" } */
|
||||
@throw invalid_1; /* { dg-error ".@throw. argument is not an object" } */
|
||||
@throw invalid_2; /* { dg-error ".@throw. argument is not an object" } */
|
||||
}
|
18
gcc/testsuite/objc.dg/exceptions-7.m
Normal file
18
gcc/testsuite/objc.dg/exceptions-7.m
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
|
||||
/* { dg-options "-fobjc-exceptions" } */
|
||||
/* { dg-do compile } */
|
||||
|
||||
/* Test warnings when the argument of @throw is invalid. */
|
||||
|
||||
#include <objc/objc.h>
|
||||
|
||||
void test (id object)
|
||||
{
|
||||
struct x { int i; } invalid_1, *invalid_2;
|
||||
|
||||
@throw object; /* Ok */
|
||||
@throw 1; /* { dg-error ".@throw. argument is not an object" } */
|
||||
@throw "string"; /* { dg-error ".@throw. argument is not an object" } */
|
||||
@throw invalid_1; /* { dg-error ".@throw. argument is not an object" } */
|
||||
@throw invalid_2; /* { dg-error ".@throw. argument is not an object" } */
|
||||
}
|
Loading…
Add table
Reference in a new issue