aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/protocol-inheritance-2.m
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-11-08 21:47:59 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-11-08 21:47:59 +0000
commit4ca5d2a7bdc3cd7182cbf0e1261a6df44d362d87 (patch)
tree72d4b2840a0a7f5a7ea5a6b60455d56effeabd73 /gcc/testsuite/objc.dg/protocol-inheritance-2.m
parent9e115cec97350099177071bb16b3efcbbacc9445 (diff)
downloadgcc-4ca5d2a7bdc3cd7182cbf0e1261a6df44d362d87.zip
gcc-4ca5d2a7bdc3cd7182cbf0e1261a6df44d362d87.tar.gz
gcc-4ca5d2a7bdc3cd7182cbf0e1261a6df44d362d87.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 (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-08 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. From-SVN: r166455
Diffstat (limited to 'gcc/testsuite/objc.dg/protocol-inheritance-2.m')
-rw-r--r--gcc/testsuite/objc.dg/protocol-inheritance-2.m57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/protocol-inheritance-2.m b/gcc/testsuite/objc.dg/protocol-inheritance-2.m
new file mode 100644
index 0000000..d769949
--- /dev/null
+++ b/gcc/testsuite/objc.dg/protocol-inheritance-2.m
@@ -0,0 +1,57 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+/* Test standard warnings when a class conforms to a protocol but some
+ methods are implemented in the superclass. Use -Wno-protocol to
+ turn these off. */
+
+@protocol MyProtocol
+- (int)method;
+@end
+
+@protocol MyProtocol2
+- (int)method2;
+@end
+
+/* The superclass implements the method required by the protocol. */
+@interface MyRootClass
+{
+ Class isa;
+}
+- (int)method;
+@end
+
+@implementation MyRootClass
+- (int)method
+{
+ return 23;
+}
+@end
+
+/* The subclass inherits the method (does not implement it directly)
+ and unless -Wno-protocol is used, we emit a warning. */
+@interface MySubClass : MyRootClass <MyProtocol>
+@end
+
+@implementation MySubClass
+@end
+
+/* { dg-warning "incomplete implementation of class .MySubClass." "" { target *-*-* } 39 } */
+/* { dg-warning "method definition for .\\-method. not found" "" { target *-*-* } 39 } */
+/* { dg-warning "class .MySubClass. does not fully implement the .MyProtocol. protocol" "" { target *-*-* } 39 } */
+
+
+/* The subclass instead does not inherit the method method2 (and does
+ not implement it directly) so it does not conform to the
+ protocol MyProtocol2. */
+@interface MySubClass2 : MyRootClass <MyProtocol2>
+@end
+
+@implementation MySubClass2
+@end /* Warnings here, below. */
+
+/* { dg-warning "incomplete implementation of class .MySubClass2." "" { target *-*-* } 53 } */
+/* { dg-warning "method definition for .\\-method2. not found" "" { target *-*-* } 53 } */
+/* { dg-warning "class .MySubClass2. does not fully implement the .MyProtocol2. protocol" "" { target *-*-* } 53 } */