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]

ObjC/ObjC++ - parse @synthesize and @dynamic


This patch implements parsing of @synthesize and @dynamic declarations in Objective-C 
and Objective-C++.  It also fixes some minor error messages when parsing invalid @class 
declarations.

The patch only deals with the parsing; it detects the declarations, parses them,
emits the appropriate syntax errors if needed, and checks that they are in the right 
@implementation context.  The actual functionality is missing (will be implemented in 
another patch); for now, after checking that the declarations are syntactically correct, 
we print an error saying that the current compiler does not support @synthesize/@dynamic.
Testcases for the syntax parsing are included.

I started the parsing code by copying from c_parser_objc_class_declaration(), which parses
the very similar @class <identifier-list>;.  I tweaked the code to adapt it to @synthesize
and @dynamic (and in the process fixed a bug I found in c_parser_objc_class_declaration() 
itself :-), testcase included with the patch), then wrote the parsing code for C++ to be almost 
identical to simplify future maintenance and changes.  I added clear comments in the code 
recommending that any change to one is mirrored into the other.  Finally, incidentally a testcase 
showed that Objective-C++ had bugs in its parsing of invalid @class declarations too, so I fixed that 
problem as well.

Ok to commit to trunk ? :-)

Thanks

PS: It's new code; we can't merge @synthesize/@dynamic from the FSF apple/trunk branch 
because they are not there.

In gcc/:
2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented parsing @synthesize and @dynamic for Objective-C.
        * c-parser.c (c_parser_external_declaration): Recognize
        RID_AT_SYNTHESIZE and RID_AT_DYNAMIC.
        (c_parser_objc_at_synthesize_declaration): New.
        (c_parser_objc_at_dynamic_declaration): New.

2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        * c-parser.c (c_parser_objc_class_declaration): After finding an
        error, parse the whole declaration then reset parser->error.

In gcc/cp/:
2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented parsing @synthesize and @dynamic for Objective-C++.
        * parser.c (cp_parser_objc_method_definition_list): Recognize
        RID_AT_SYNTHESIZE and RID_AT_DYNAMIC.
        (cp_parser_objc_at_dynamic_declaration): New.
        (cp_parser_objc_at_synthesize_declaration): New.

2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        * parser.c (cp_parser_objc_identifier_list): Check the return
        value of cp_parser_identifier and react if it is error_mark_node.

In gcc/objc/:
2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented parsing @synthesize and @dynamic for
        Objective-C/Objective-C++.
        * objc-act.c (objc_add_synthesize_declaration): New.
        (objc_add_dynamic_declaration): New.

2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc-act.c (lookup_and_install_protocols): Return NULL if passed
        error_mark_node.

In gcc/testsuite/:
2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented parsing @synthesize and @dynamic for
        Objective-C/Objective-C++.
        * objc.dg/property/dynamic-1.m: New.
        * objc.dg/property/synthesize-1.m: New.
        * obj-c++.dg/property/dynamic-1.mm: New.
        * obj-c++.dg/property/synthesize-1.mm: New.

2010-10-18  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc.dg/at-class-1.m: New.
        * objc.dg/at-class-1.mm: New.

Attachment: patch.txt
Description: Text document


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