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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc.dg/] [func-ptr-1.m] - Diff between revs 154 and 816

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

Rev 154 Rev 816
/* Test for handling of function pointer ivars */
/* Test for handling of function pointer ivars */
/* { dg-do run } */
/* { dg-do run } */
 
 
#include <objc/Object.h>
#include <objc/Object.h>
 
 
extern int strcmp(const char *, const char *);
extern int strcmp(const char *, const char *);
extern void abort(void);
extern void abort(void);
#define CHECK_IF(expr) if(!(expr)) abort()
#define CHECK_IF(expr) if(!(expr)) abort()
 
 
typedef float (*floatfunc)(float, float);
typedef float (*floatfunc)(float, float);
 
 
@interface MyObject : Object
@interface MyObject : Object
{
{
@public
@public
  int (*ivar)(int, int, int);
  int (*ivar)(int, int, int);
  floatfunc ffunc;
  floatfunc ffunc;
}
}
- init;
- init;
@end
@end
 
 
int foo(int a, int b, int c) {
int foo(int a, int b, int c) {
  return a + b + c;
  return a + b + c;
}
}
 
 
float bar(float a, float b) {
float bar(float a, float b) {
  return a * b;
  return a * b;
}
}
 
 
@implementation MyObject
@implementation MyObject
- init {
- init {
  [super init];
  [super init];
  ivar = foo;
  ivar = foo;
  ffunc = bar;
  ffunc = bar;
  return self;
  return self;
}
}
@end
@end
 
 
int main ()
int main ()
{
{
  MyObject *obj = [[MyObject alloc] init];
  MyObject *obj = [[MyObject alloc] init];
  const char *enc = @encode(MyObject);
  const char *enc = @encode(MyObject);
 
 
  CHECK_IF(obj->ivar(4, 5, 6) == 15);
  CHECK_IF(obj->ivar(4, 5, 6) == 15);
  CHECK_IF(obj->ffunc(34.0, 45.0) == 34.0 * 45.0);
  CHECK_IF(obj->ffunc(34.0, 45.0) == 34.0 * 45.0);
  CHECK_IF(!strcmp(enc, "{MyObject=#^?^?}"));
  CHECK_IF(!strcmp(enc, "{MyObject=#^?^?}"));
  return(0);
  return(0);
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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