summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/property/at-property-20.m
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/objc.dg/property/at-property-20.m
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/objc.dg/property/at-property-20.m')
-rw-r--r--gcc/testsuite/objc.dg/property/at-property-20.m81
1 files changed, 81 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/property/at-property-20.m b/gcc/testsuite/objc.dg/property/at-property-20.m
new file mode 100644
index 000000000..1bb49da2b
--- /dev/null
+++ b/gcc/testsuite/objc.dg/property/at-property-20.m
@@ -0,0 +1,81 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+/* Test that if you have a property declared in a class and a
+ sub-class, the types match (unless it's a readonly property, in
+ which case a "specialization" is enough). */
+
+@protocol MyProtocolA
+- (void) doNothingA;
+@end
+
+@protocol MyProtocolB
+- (void) doNothingB;
+@end
+
+@interface MyRootClass
+{
+ Class isa;
+}
+@end
+
+@interface MySubClass1 : MyRootClass
+@end
+
+@interface MySubClass2 : MyRootClass
+@end
+
+@interface MySubClass3 : MyRootClass <MyProtocolA>
+@end
+
+@interface MySubClass4 : MySubClass1
+@end
+
+/* Now, the test. */
+
+@interface MyClass : MyRootClass
+{ }
+@property (assign) id <MyProtocolA> a; /* { dg-message "originally specified here" } */
+@property int b; /* { dg-message "originally specified here" } */
+@property float c; /* { dg-message "originally specified here" } */
+@property (assign) MyRootClass *d; /* { dg-message "originally specified here" } */
+@property (assign) MySubClass1 *e; /* { dg-message "originally specified here" } */
+@property (assign, readonly) MySubClass1 *f; /* { dg-message "originally specified here" } */
+@property (assign) MySubClass3 *g; /* { dg-message "originally specified here" } */
+@property (assign, readonly) MySubClass3 *h; /* { dg-message "originally specified here" } */
+@end
+
+/* The following are all OK because they are identical. */
+@interface MyClass2 : MyClass
+{ }
+@property (assign) id a;
+@property int b;
+@property float c;
+@property (assign) MyRootClass *d;
+@property (assign) MySubClass1 *e;
+@property (assign, readonly) MySubClass1 *f;
+@property (assign) MySubClass3 *g;
+@property (assign, readonly) MySubClass3 *h;
+@end
+
+/* The following are not OK. */
+@interface MyClass3 : MyClass
+{ }
+@property (assign) MySubClass1 *a; /* { dg-warning "type of property .a. conflicts with previous declaration" } */
+@property float b; /* { dg-warning "type of property .b. conflicts with previous declaration" } */
+@property int c; /* { dg-warning "type of property .c. conflicts with previous declaration" } */
+@property (assign) id d; /* { dg-warning "type of property .d. conflicts with previous declaration" } */
+@property (assign) MyRootClass *e; /* { dg-warning "type of property .e. conflicts with previous declaration" } */
+@property (assign, readonly) MyRootClass *f; /* { dg-warning "type of property .f. conflicts with previous declaration" } */
+@property (assign) MySubClass2 *g; /* { dg-warning "type of property .g. conflicts with previous declaration" } */
+@property (assign, readonly) MySubClass2 *h; /* { dg-warning "type of property .h. conflicts with previous declaration" } */
+@end
+
+/* The following are OK. */
+@interface MyClass4 : MyClass
+{ }
+@property (assign, readonly) MySubClass4 *f;
+@property (assign, readonly) MySubClass3 <MyProtocolB> *h;
+@end