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++ - another wave of @property fixes


This patch fixes a few bugs and issues with our implementation of properties:

 * it allows @dynamic in categories.  It should be allowed, but we didn't allow it (and
the corresponding lookup for the @property in the category was missing, hence it wouldn't
work - now it does).

 * it adds the -Wno-property-assign-default flag (identical to Apple's GCC flag) to
disable the warnings when an object property has no assign semantics specified.  These 
warnings were forcefully turned on regardless (but the warnings may well be wrong in a
number of situations), which can be a problem.  This patch adds the ability to turn them off,
exactly like in Apple's Objective-C 2.0 compiler.

 * it also turns off the warnings when the property is readonly

 * it also turns off these warnings when the property is of type Class

 * it also turns off these warnings when the property is of type "NSObject **" (or 
"id ****" or any other multiple indirection pointer) as these are simply not
Objective-C objects

 * incidentally, the same check is used in the fast enumeration for invalid looping variables 
and invalid collection objects so this patch fixes these checks as well (eg, a collection
of type "id ****" correctly generates a warning now if used in a fast enumeration)

I included testcases for all of these.

Ok to commit to trunk ?

Thanks

PS: I am bugfixing and polishing @property/@dynamic/@synthesize to get them ready for release (which 
is what stage 3 is about); but some of the polishing changes (such as the addition of the 
-Wno-property-assign-default flag above) are borderline between a bugfix and a new feature. 
They are really needed and are very low risk, with no effect outside of ObjC (where 
I'm adding lots of testcase for each change), so I'd ask permission to go ahead with them even 
if we are in stage 3.  I'll try to do them all ASAP in the first week of stage 3. :-)


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

        * objc-act.c (objc_add_dynamic_declaration): Allow @dynamic in a
        category.
        (objc_type_valid_for_messaging): Added 'accept_classes' argument;
        if set to 'true', return 'true' for Class objects.  Do not remove
        more than on pointer indirection.
        (objc_add_property_declaration): Only warn about 'assign'
        semantics for Objective-C objects if warn_property_assign_default;
        and do not warn if the property is readonly or if the type is a Class.
        (objc_finish_foreach_loop): Updated calls to
        objc_type_valid_for_messaging.

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

        * objc.dg/property/dynamic-2.m: Updated for the fact that @dynamic
        is now allowed in categories.
        * obj-c++.dg/property/dynamic-2.mm: Same change.
        * objc.dg/property/dynamic-3.m: New.
        * obj-c++.dg/property/dynamic-3.mm: New.
        * objc.dg/property/at-property-14.m: New.
        * objc.dg/property/at-property-15.m: New.
        * obj-c++.dg/property/at-property-14.mm: New.
        * obj-c++.dg/property/at-property-15.mm: New.

        * objc.dg/foreach-6.m: Added a few more tests for valid and
        invalid iterating variables and collections.

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]