Fix broken MinGW build of gcc.c
[official-gcc.git] / gcc / testsuite / obj-c++.dg / template-8.mm
blobdf215b8525d287697d774bc28c67ee23c0027b22
1 /* Test that all pending instantiations have taken place before meta-data
2    generation. */       
3 /* Author: Fariborz Jahanian <fjahanian@apple.com> */
4 /* Adapted by Nicola Pero <nicola.pero@meta-innovation.com> */
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" } { "" } } */
9 #include <objc/objc.h>
10 #include <objc/runtime.h>
12 @interface MyRootClass
13 { Class isa; }
14 + (id) initialize;
15 + alloc;
16 - init;
17 - doSomething;
18 @end
20 @implementation MyRootClass
21 + (id) initialize { return self; }
22 + alloc { return class_createInstance (self, 0); }
23 - init  { return self; }
24 - doSomething { return self; }
25 @end
27 class Base
29 public:
30         Base() { }
31         virtual ~Base() { }
32         
33         void destroy() { delete this; }
36 template<class T>
37 class Subclass : public T
39 public:
40         Subclass() { }
41         
42         virtual ~Subclass()
43         {
44                 [[[MyRootClass alloc] init] doSomething];
45         }
48 int main(int argc, const char * argv[])
50     Subclass<Base>* theSubclass = new Subclass<Base>();
51     theSubclass->destroy();
52     return 0;