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] |
This new ObjC/ObjC++ patch contains another group of @property/@synthesize type fixes and improvements: * it removes an incorrect warning when 'assign' is used in a @property declaration with 'Class <MyProtocol>'. * it allows the type of an instance variable for a @synthesized property to be "more specialized" than the type of the property, if the property is read-only. * it detects and rejects attempts to declare @properties of type array or which are bit-fields, which are invalid. * it allows a bit-field instance variable to be used by @synthesize. The runtime getter/setter helpers do not work with bit-field instance variables though, so I added explicit checks that the @property was 'nonatomic' and 'assign' to make sure that direct variable access (which works fine with bit-field variables) could be used when generating the accessors. I doubt bit-fields would be used much with properties; it's nice to have them for completeness though. * it tidies up some warnings and errors. It's sometimes hard to decide what should be a warning and what should be an error and I changed my mind a few times. Anyway, in the end I'm leaving most of the errors and warnings as they are, with two exceptions: if a property is declared readonly, and a getter is specified at the same time, I made that into an error because it does seem very inconsistent and the compiler can't guess what is meant; error recovery (ie, ignoring one of the two) would have to kick in and that seems to be an error situation. Vice versa, if a @property is re-declared in a subclass with different attributes, I changed these to be warnings as opposed to errors because we can compile everything fine and there may be reasons why it does not matter and everything will actually work (eg, maybe one of the properties is never actually used; I suppose it is also possible that all property accesses are done using accurate casts to make sure the right property is picked up). We still warn and you can't really turn off the warnings, which is still quite heavy, but we don't refuse to compile any more. Testcases for all of the changes above are included. I also added a couple of testcases testing properties of type 'enum' and of other types, just to make sure there are no surprises. I also figured out that most of the ObjC++ testsuite issues I had go away if you use dg-warning instead of dg-message to match things like "note: originally specified here". I updated the relevant ObjC++ testcases and was able to enable them so we have a better ObjC++ testsuite coverage. Ok to commit to trunk ? Thanks PS: It's all starting to be in good shape. The main key remaining problems to work on are: * ObjC 2.0 dot-syntax accessors don't work in quite a few cases (object.property++, object.property1 = object.property2 = x etc) * @optional + @property does not work * the checks that user-generated setters/getters have the right signature are missing I guess I am a few patches away from finishing (even if I felt "a few patches away" for the past few weeks (if not months), but now it seems I may really be) :-) In gcc/objc/: 2010-11-13 Nicola Pero <nicola.pero@meta-innovation.com> * objc-act.c (objc_add_property_declaration): Check that the decl we received from the parser is a FIELD_DECL; reject array and bitfield properties. Convert the warning when a property is readonly and a setter is specified into an error. Convert errors when a property declaration does not match a property declaration in a superclass into warnings. (objc_add_synthesize_declaration_for_property): Use DECL_BIT_FIELD_TYPE to determine the type of an instance variable if it is a bitfield. Throw an error if we are asked to synthesize setters/getters for a bitfield instance variable but the property is not appropriate - it must be assign and nonatomic. If the property is readonly, allow the instance variable type to be a specialization of the property type. (objc_type_valid_for_messaging): Fixed returning 'false' for a Class qualified with a protocol when the 'accept_classes' argument is 'false'. In gcc/testsuite/: 2010-11-13 Nicola Pero <nicola.pero@meta-innovation.com> * objc.dg/property/at-property-21.m: New. * objc.dg/property/at-property-22.m: New. * objc.dg/property/at-property-23.m: New. * objc.dg/property/synthesize-9.m: New. * objc.dg/property/synthesize-10.m: New. * objc.dg/property/synthesize-11.m: New. * obj-c++.dg/property/at-property-21.mm: New. * obj-c++.dg/property/at-property-22.mm: New. * obj-c++.dg/property/at-property-23.mm: New. * obj-c++.dg/property/synthesize-9.mm: New. * obj-c++.dg/property/synthesize-10.mm: New. * obj-c++.dg/property/synthesize-11.mm: New. * objc.dg/property/at-property-4.m: Updated to match new compiler where some errors have been converted into warnings and vice versa. * objc.dg/property/at-property-16.m: Same change. * objc.dg/property/at-property-18.m: Same change. * objc.dg/property/property-neg-5.m: Same change. * obj-c++.dg/property/at-property-4.mm: Same change. * obj-c++.dg/property/at-property-16.mm: Same change. * obj-c++.dg/property/at-property-18.mm: Same change. * obj-c++.dg/property/property-neg-5.mm: Same change. * obj-c++.dg/property/dynamic-2.mm: Enable tests that were commented out because of testsuite problems; I found out that using dg-warning instead of dg-message gets them to work. * obj-c++.dg/property/property-neg-3.mm: Same change. * obj-c++.dg/property/synthesize-6.mm: Same change. * obj-c++.dg/property/at-property-5.mm: Same change. * obj-c++.dg/property/at-property-14.mm: Same change. * obj-c++.dg/property/at-property-18.mm: Same change. * obj-c++.dg/property/at-property-16.mm: Same change (in this file, some tests still do not work due to some other testsuite issue).
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] |