diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-11-08 22:38:04 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-11-08 22:38:04 +0000 |
commit | d36dba07390dd63b6ac1a8b531cc6864605c56eb (patch) | |
tree | 6d9394924935e5c8e58b7b3ad2e852031f2886e7 /gcc/objc/objc-act.c | |
parent | 4741888d0321172ac91ee71c6a035d1048b49f39 (diff) | |
download | gcc-d36dba07390dd63b6ac1a8b531cc6864605c56eb.zip gcc-d36dba07390dd63b6ac1a8b531cc6864605c56eb.tar.gz gcc-d36dba07390dd63b6ac1a8b531cc6864605c56eb.tar.bz2 |
In gcc/objc/: 2010-11-08 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/:
2010-11-08 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_add_dynamic_declaration_for_property): Do not
search for the @property declation only in the current context,
but also in inherited properties. Do not mark the original
PROPERTY_DECL in the @interface or @protocol with
PROPERTY_DYNAMIC.
(check_methods): To check if a method is associated with a
@dynamic property, search for the property in IMPL_PROPERTY_DECL.
(check_accessible_methods): Same change.
* objc-act.h: Updated comment.
In gcc/testsuite/:
2010-11-08 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/property/dynamic-4.m: New.
* objc.dg/property/dynamic-5.m: New.
* objc.dg/property/dynamic-6.m: New.
* obj-c++.dg/property/dynamic-4.mm: New.
* obj-c++.dg/property/dynamic-5.mm: New.
* obj-c++.dg/property/dynamic-6.mm: New.
2010-11-08 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/property/dotsyntax-13.m: New.
* objc.dg/property/dotsyntax-14.m: New.
* objc.dg/property/dotsyntax-15.m: New.
* objc.dg/property/synthesize-7.m: New.
* obj-c++.dg/property/dotsyntax-13.mm: New.
* obj-c++.dg/property/dotsyntax-14.mm: New.
* obj-c++.dg/property/dotsyntax-15.mm: New.
* obj-c++.dg/property/synthesize-7.mm: New.
From-SVN: r166457
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r-- | gcc/objc/objc-act.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index ff69414..eee98e4 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -8738,9 +8738,19 @@ check_methods (tree chain, tree implementation, int mtype) { /* If the method is associated with a dynamic property, then it is Ok not to have the method implementation, as it will be - generated dynamically at runtime. */ - tree property = METHOD_PROPERTY_CONTEXT (chain); - if (property != NULL_TREE && PROPERTY_DYNAMIC (property)) + generated dynamically at runtime. To decide if the method is + associated with a @dynamic property, we search the list of + @synthesize and @dynamic for this implementation, and look + for any @dynamic property with the same setter or getter name + as this method. */ + tree x; + for (x = IMPL_PROPERTY_DECL (implementation); x; x = TREE_CHAIN (x)) + if (PROPERTY_DYNAMIC (x) + && (PROPERTY_GETTER_NAME (x) == METHOD_SEL_NAME (chain) + || PROPERTY_SETTER_NAME (x) == METHOD_SEL_NAME (chain))) + break; + + if (x != NULL_TREE) { chain = TREE_CHAIN (chain); /* next method... */ continue; @@ -8751,6 +8761,7 @@ check_methods (tree chain, tree implementation, int mtype) /* If the method is a property setter/getter, we'll still allow it to be missing if it is implemented by 'interface' or any of its superclasses. */ + tree property = METHOD_PROPERTY_CONTEXT (chain); if (property) { /* Note that since this is a property getter/setter, it @@ -8864,13 +8875,21 @@ check_methods_accessible (tree chain, tree context, int mtype) { /* If the method is associated with a dynamic property, then it is Ok not to have the method implementation, as it will be - generated dynamically at runtime. */ - tree property = METHOD_PROPERTY_CONTEXT (chain); - if (property != NULL_TREE && PROPERTY_DYNAMIC (property)) + generated dynamically at runtime. Search for any @dynamic + property with the same setter or getter name as this + method. TODO: Use a hashtable lookup. */ + tree x; + for (x = IMPL_PROPERTY_DECL (base_context); x; x = TREE_CHAIN (x)) + if (PROPERTY_DYNAMIC (x) + && (PROPERTY_GETTER_NAME (x) == METHOD_SEL_NAME (chain) + || PROPERTY_SETTER_NAME (x) == METHOD_SEL_NAME (chain))) + break; + + if (x != NULL_TREE) { chain = TREE_CHAIN (chain); /* next method... */ continue; - } + } context = base_context; while (context) @@ -9910,11 +9929,9 @@ objc_add_dynamic_declaration_for_property (location_t location, tree interface, return; } - /* Check that the property is declared in the corresponding - interface. */ - for (property = CLASS_PROPERTY_DECL (interface); property; property = TREE_CHAIN (property)) - if (PROPERTY_NAME (property) == property_name) - break; + /* Check that the property is declared in the interface. It could + also be declared in a superclass or protocol. */ + property = lookup_property (interface, property_name); if (!property) { @@ -9924,17 +9941,6 @@ objc_add_dynamic_declaration_for_property (location_t location, tree interface, } else { - /* Mark the original PROPERTY_DECL as dynamic. The reason is - that the setter and getter methods in the interface have a - METHOD_PROPERTY_CONTEXT that points to the original - PROPERTY_DECL; when we check that these methods have been - implemented, we need to easily find that they are associated - with a dynamic property. TODO: Remove this hack; it will not - work with properties in a protocol that may be implemented by - different classes and be @dynamic in some, and non-@dynamic - in other ones. */ - PROPERTY_DYNAMIC (property) = 1; - /* We have to copy the property, because we want to chain it to the implementation context, and we want to store the source location of the @synthesize, not of the original |