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" } { "" } } */ 8 9#include <objc/objc.h> 10#include <objc/runtime.h> 11 12@interface MyRootClass 13{ Class isa; } 14+ (id) initialize; 15+ alloc; 16- init; 17- doSomething; 18@end 19 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 26 27class Base 28{ 29public: 30 Base() { } 31 virtual ~Base() { } 32 33 void destroy() { delete this; } 34}; 35 36template<class T> 37class Subclass : public T 38{ 39public: 40 Subclass() { } 41 42 virtual ~Subclass() 43 { 44 [[[MyRootClass alloc] init] doSomething]; 45 } 46}; 47 48int main(int argc, const char * argv[]) 49{ 50 Subclass<Base>* theSubclass = new Subclass<Base>(); 51 theSubclass->destroy(); 52 return 0; 53} 54