Debian Codegraph @

gcc/testsuite/objc.dg/special/unclaimed-category-1.m

raw
1 /* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4 /* { dg-additional-options "-Wno-objc-root-class" } */
5
6 #include <objc/objc.h>
7 #include "../../objc-obj-c++-shared/runtime.h"
8
9 extern void abort (void);
10
11 /* Test loading unclaimed categories - categories of a class defined
12 separately from the class itself. */
13
14
15 /* unclaimed-category-1.m contains only the class definition but not
16 the categories. unclaimed-category-1a.m contains only the
17 categories of the class, but not the class itself. We want to
18 check that the runtime can load the class from one module (file)
19 and the categories from another module (file). */
20
21 #include "unclaimed-category-1.h"
22
23 @implementation TestClass
24 - (int)D
25 {
26 return 4;
27 }
28 + initialize { return self; }
29 @end
30
31
32 int main (void)
33 {
34 TestClass *test;
35 Class testClass;
36
37 testClass = objc_getClass ("TestClass");
38 if (testClass == Nil)
39 {
40 abort ();
41 }
42
43 test = (TestClass *)(class_createInstance (testClass, 0));
44 if (test == nil)
45 {
46 abort ();
47 }
48
49 if ([test A] != 1)
50 {
51 abort ();
52 }
53
54 if ([test B] != 2)
55 {
56 abort ();
57 }
58
59 if ([test C] != 3)
60 {
61 abort ();
62 }
63
64
65 if ([test D] != 4)
66 {
67 abort ();
68 }
69
70 return 0;
71 }