Debian Codegraph @

gcc/testsuite/obj-c++.dg/template-8.mm

raw
1 /* Test that all pending instantiations have taken place before meta-data
2 generation. */
3 /* Author: Fariborz Jahanian <[email protected]> */
4 /* Adapted by Nicola Pero <[email protected]> */
5 /* { dg-do run } */
6 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
7 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
8 // { dg-additional-options "-Wno-objc-root-class" }
9
10 #include <objc/objc.h>
11 #include <objc/runtime.h>
12
13 @interface MyRootClass
14 { Class isa; }
15 + (id) initialize;
16 + alloc;
17 - init;
18 - doSomething;
19 @end
20
21 @implementation MyRootClass
22 + (id) initialize { return self; }
23 + alloc { return class_createInstance (self, 0); }
24 - init { return self; }
25 - doSomething { return self; }
26 @end
27
28 class Base
29 {
30 public:
31 Base() { }
32 virtual ~Base() { }
33
34 void destroy() { delete this; }
35 };
36
37 template<class T>
38 class Subclass : public T
39 {
40 public:
41 Subclass() { }
42
43 virtual ~Subclass()
44 {
45 [[[MyRootClass alloc] init] doSomething];
46 }
47 };
48
49 int main(int argc, const char * argv[])
50 {
51 Subclass<Base>* theSubclass = new Subclass<Base>();
52 theSubclass->destroy();
53 return 0;
54 }