OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [class_self-2.m] - Diff between revs 149 and 154

Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
/* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */
/* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */
#include <objc/objc.h>
#include <objc/objc.h>
 
 
/* Test calling a class method on self where self has been redefined
/* Test calling a class method on self where self has been redefined
   to be another class - the call requires a cast */
   to be another class - the call requires a cast */
 
 
 
 
/* The first class */
/* The first class */
struct d
struct d
{
{
  int a;
  int a;
};
};
 
 
@interface ClassA
@interface ClassA
{
{
  Class isa;
  Class isa;
}
}
+ (Class) class;
+ (Class) class;
+ (struct d) method;
+ (struct d) method;
@end
@end
 
 
@implementation ClassA
@implementation ClassA
+ (Class) class
+ (Class) class
{
{
  return self;
  return self;
}
}
 
 
+ (struct d) method
+ (struct d) method
{
{
  struct d u;
  struct d u;
  u.a = 5;
  u.a = 5;
 
 
  return u;
  return u;
}
}
#ifdef __NEXT_RUNTIME__                                   
#ifdef __NEXT_RUNTIME__                                   
+ initialize { return self; }
+ initialize { return self; }
#endif
#endif
@end
@end
 
 
/* The second class */
/* The second class */
@interface TestClass
@interface TestClass
{
{
  Class isa;
  Class isa;
}
}
+ (void) test;
+ (void) test;
@end
@end
 
 
@implementation TestClass
@implementation TestClass
+ (void) test
+ (void) test
{
{
  self = [ClassA class];
  self = [ClassA class];
 
 
 
 
  if ([(Class)self method].a != 5)
  if ([(Class)self method].a != 5)
    {
    {
      abort ();
      abort ();
    }
    }
}
}
 
 
#ifdef __NEXT_RUNTIME__                                   
#ifdef __NEXT_RUNTIME__                                   
+ initialize { return self; }
+ initialize { return self; }
#endif
#endif
@end
@end
 
 
 
 
int main (void)
int main (void)
{
{
  [TestClass test];
  [TestClass test];
 
 
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.