This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ObjC/ObjC++: bug fixes for @catch


Hi Nicola,

Looks great!
(a couple of points below).


On 28 Nov 2010, at 00:24, Nicola Pero wrote:


This patch fixes a number of bugs, minor and missing/incomplete checks (and some ICEs) in GCC's parsing
of Objective-C @catch syntax.


I started work on this patch by running GCC 4.6.0 against a number of @try/@throw/@catch/@finally
testcases in clang. I fixed all problems that these highlighted in GCC with respect to @catch,
and I tidied up a number of additional cases and problems that came up while studying the testcases.


This patch:

* implements the syntax "@catch(...)" which was missing. With this patch, this syntax is parsed and
is equivalent to "@catch (id temporary_unused_variable)" (ie, no integration with C++; once better
integration with C++ is implemented, @catch(...) is supposed to also catch C++ exceptions. Not for 4.6).
4 testcases (one for parsing, one for executing for both ObjC and ObjC++) are included (sadly, as it is
well-known (PR objc++/23616), ObjC exceptions don't actually work in ObjC++, so I had to disable the
ObjC++ execution one as fixing that is not part of this patch. I don't think I'll work on that for 4.6,
it's too late)

... but they should work for NeXT runtime ;-)
(currently the new tests, along with some changed and older ones all ICE with a canonical type comparison problem).


* implements better type-checking for the argument of @catch(). In particular, arguments that are
protocol-qualified are now (correctly) rejected. Testcases included, showing various types of arguments
that are accepted or rejected (PS: before this patch, both the exceptions-3.m and exceptions-5.m testcases
would not only accept invalid arguments, but actually ICE the compiler).


* improves error recovery when parsing invalid @catch(){} clauses. Testcases included, showing a number
of cases of typos and localized errors and the results.


* makes the ObjC and ObjC++ parsing code very similar

Ok to commit ?

Thanks

In gcc/objc/:
2010-11-28  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-28  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.

I think we can honestly forecast needing enough exception tests to warrant starting a new directory for them --
... also we should identify suitable candidates for torture testing - which is especially weak for Obj-C++


obj*.dg/exceptions/
obj*.dg/torture/exceptions/

the .exp scripts in an existing parallel dir should serve as a template
(or let me know off-list and I'll do this and send you an increment to your patch)


cheers
Iain


In gcc/cp/: 2010-11-28 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-28  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.
<patch.txt>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]