URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 308 |
Rev 384 |
/* Test for using ObjC classes as C++ template parameters. */
|
/* Test for using ObjC classes as C++ template parameters. */
|
/* Author: Ziemowit Laski . */
|
/* Author: Ziemowit Laski . */
|
|
|
/* { dg-do run } */
|
/* { dg-do run } */
|
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
|
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
|
#include "../objc-obj-c++-shared/Object1.h"
|
#include "../objc-obj-c++-shared/Object1.h"
|
#include
|
#include
|
|
|
#define CHECK_IF(expr) if(!(expr)) abort()
|
#define CHECK_IF(expr) if(!(expr)) abort()
|
|
|
@interface Base: Object
|
@interface Base: Object
|
- (int) meth;
|
- (int) meth;
|
@end
|
@end
|
|
|
@interface Derived: Base
|
@interface Derived: Base
|
- (int) meth;
|
- (int) meth;
|
@end
|
@end
|
|
|
static int count = 0;
|
static int count = 0;
|
|
|
template struct Templ
|
template struct Templ
|
{
|
{
|
T *m;
|
T *m;
|
int i;
|
int i;
|
Templ(): i(55), m([[T alloc] init]) { count++; }
|
Templ(): i(55), m([[T alloc] init]) { count++; }
|
~Templ() { [m free]; count--; }
|
~Templ() { [m free]; count--; }
|
};
|
};
|
|
|
@implementation Base
|
@implementation Base
|
- (int) meth { return 333; }
|
- (int) meth { return 333; }
|
@end
|
@end
|
|
|
@implementation Derived
|
@implementation Derived
|
- (int) meth { return 666; }
|
- (int) meth { return 666; }
|
@end
|
@end
|
|
|
int main (void) {
|
int main (void) {
|
CHECK_IF(count == 0);
|
CHECK_IF(count == 0);
|
{
|
{
|
Templ derived;
|
Templ derived;
|
CHECK_IF(derived.i == 55 && count == 1);
|
CHECK_IF(derived.i == 55 && count == 1);
|
Templ base;
|
Templ base;
|
CHECK_IF(base.i == 55 && count == 2);
|
CHECK_IF(base.i == 55 && count == 2);
|
CHECK_IF([base.m meth] == 333);
|
CHECK_IF([base.m meth] == 333);
|
CHECK_IF([derived.m meth] == 666);
|
CHECK_IF([derived.m meth] == 666);
|
}
|
}
|
CHECK_IF(count == 0);
|
CHECK_IF(count == 0);
|
return 0;
|
return 0;
|
}
|
}
|
#include "../objc-obj-c++-shared/Object1-implementation.h"
|
#include "../objc-obj-c++-shared/Object1-implementation.h"
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.