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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [obj-c++.dg/] [template-1.mm] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 308 jeremybenn
/* Test for using ObjC classes as C++ template parameters.  */
2
/* Author:  Ziemowit Laski .  */
3
 
4
/* { dg-do run } */
5
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6
#include "../objc-obj-c++-shared/Object1.h"
7
#include 
8
 
9
#define CHECK_IF(expr) if(!(expr)) abort()
10
 
11
@interface Base: Object
12
- (int) meth;
13
@end
14
 
15
@interface Derived: Base
16
- (int) meth;
17
@end
18
 
19
static int count = 0;
20
 
21
template  struct Templ
22
{
23
  T *m;
24
  int i;
25
  Templ(): i(55), m([[T alloc] init]) { count++; }
26
  ~Templ() { [m free]; count--; }
27
};
28
 
29
@implementation Base
30
- (int) meth { return 333; }
31
@end
32
 
33
@implementation Derived
34
- (int) meth { return 666; }
35
@end
36
 
37
int main (void) {
38
  CHECK_IF(count == 0);
39
  {
40
    Templ derived;
41
    CHECK_IF(derived.i == 55 && count == 1);
42
    Templ base;
43
    CHECK_IF(base.i == 55 && count == 2);
44
    CHECK_IF([base.m meth] == 333);
45
    CHECK_IF([derived.m meth] == 666);
46
  }
47
  CHECK_IF(count == 0);
48
  return 0;
49
}
50
#include "../objc-obj-c++-shared/Object1-implementation.h"

powered by: WebSVN 2.1.0

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