aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m')
-rw-r--r--gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m b/gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m
new file mode 100644
index 000000000..9ca4aebbe
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m
@@ -0,0 +1,47 @@
+/* Contributed by Nicola Pero - Sat 8 Oct 2011 16:47:48 BST */
+#include <objc/objc.h>
+
+/* Test that if a class has no +initialize method, the superclass
+ implementation is called. */
+
+static int class_variable = 0;
+
+@interface TestClass
+{
+ Class isa;
+}
++ (void) initialize;
++ (int) classVariable;
+@end
+
+@implementation TestClass
++ (void) initialize
+{
+ class_variable++;
+}
++ (int) classVariable
+{
+ return class_variable;
+}
+@end
+
+@interface TestSubClass : TestClass
+@end
+
+@implementation TestSubClass
+@end
+
+int main (void)
+{
+ if ([TestClass classVariable] != 1)
+ {
+ abort ();
+ }
+
+ if ([TestSubClass classVariable] != 2)
+ {
+ abort ();
+ }
+
+ return 0;
+}