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


This patch fixes a bunch of missing (or incorrect) warnings and checks for @properties --

 * adds some missing checks for a @property declaration.  When a @property is declared, with this patch we now 
check for existing @property declarations that would be inherited, and check that the attributes are compatible.  In 
particular, nonatomic / assign semantics / setter / getter attributes must be identical; readonly can be overridden
with readwrite (but not vice versa).

 * removes warnings when a setter/getter for a @property is inherited instead of being implemented directly.  In
particular, this is useful when you have a readonly property and want to override it with a readwrite one; you may
want to implement only the setter, while inheriting the getter as it is (and that should generate no warnings).

 * it adds some testcases for a similar situation with protocols; in that case, though, there was nothing to implement
as we already have the -Wno-protocol switch that allows you to decide if you want a warning or not when a method in a class
conforming to a protocol is inherited as opposed to directly implemented in the class.  The two testcases show that this
works exactly as documented (and still works as documented after my changes to method lookup) with both the -Wno-protocol 
and the -Wprotocol switches (turning the warnings on or off).

 * it fixes looking up a @property in a protocol attached to a category of a superclass.

Testcases for all the above are included.

Ok to commit to trunk ?

Thanks

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

        * objc-act.c (lookup_property): When checking categories, also
        check the protocols attached to each.
        (objc_add_property_declaration): Determine the
        PROPERTY_SETTER_NAME and PROPERTY_GETTER_NAME here.  Tidied up
        error message.  Search for an existing property declaration with
        the same name which would be inherited from the class hiearchy,
        and produce an error if it has incompatible attributes.
        (check_methods): Changed second parameter.  If the method is a
        getter or setter for a property, do not warn if it is inherited as
        opposed to implemented directly in the class.
        (check_protocol): Updated calls to check_methods.
        (finish_class): Do not determine the PROPERTY_SETTER_NAME and
        PROPERTY_GETTER_NAME here; this is now done earlier, in
        objc_add_property_declaration.
        * objc-act.h (CLASS_NAME, CLASS_SUPER_NAME): Added comments.

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

        * objc.dg/property/at-property-5.m: Updated test.
        * objc.dg/property/at-property-16.m: New.
        * objc.dg/property/at-property-17.m: New.
        * objc.dg/property/at-property-18.m: New.
        * objc.dg/property/at-property-19.m: New.
        * objc.dg/property/dotsyntax-12.m: New
        * objc.dg/protocol-inheritance-1.m: New.
        * objc.dg/protocol-inheritance-2.m: New.
        * obj-c++.dg/property/at-property-5.mm: Updated test.
        * obj-c++.dg/property/at-property-16.mm: New.
        * obj-c++.dg/property/at-property-17.mm: New.
        * obj-c++.dg/property/at-property-18.mm: New.
        * obj-c++.dg/property/at-property-19.mm: New.
        * obj-c++.dg/protocol-inheritance-1.mm: New.
        * obj-c++.dg/protocol-inheritance-2.mm: New.
        * obj-c++.dg/property/dotsyntax-12.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]