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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [obj-c++.dg/] [template-4.mm] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 308 jeremybenn
/* Author:  Ziemowit Laski .  */
2
 
3
/* { dg-do run } */
4
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5
#include "../objc-obj-c++-shared/Object1.h"
6
#include "../objc-obj-c++-shared/next-mapping.h"
7
#include 
8
#include 
9
 
10
#ifndef __NEXT_RUNTIME__
11
#include 
12
#endif
13
 
14
#define CHECK_IF(expr) if(!(expr)) abort()
15
 
16
template  class TestT
17
{
18
public:
19
  TYPE k;
20
  int abc(ARR *array) {
21
    return [array count] * k;
22
  }
23
  TestT(TYPE _k): k(_k) { }
24
};
25
 
26
template 
27
const char *getDesc(void) {
28
  return [TYPE name];
29
}
30
 
31
@class Array;
32
 
33
template 
34
int abc(TYPE *xyz, Array *array) {
35
  return [xyz count] + [array count];
36
}
37
 
38
@interface Array: Object {
39
  id *arr;
40
  int count;
41
}
42
+ (id)arrayWithObjects:(id)first, ... ;
43
- (int)count;
44
@end
45
 
46
@implementation Array
47
+ (id)arrayWithObjects:(id)first, ... {
48
  Array *a = [Array new];
49
  a->count = 0;
50
  a->arr = (id *) calloc(8, sizeof(id));
51
 
52
  va_list args;
53
  va_start (args, first);
54
 
55
  a->arr[a->count++] = first;
56
 
57
  for (id el; el = va_arg(args, id); a->count++)
58
    a->arr[a->count] = el;
59
 
60
  return a;
61
}
62
- (int)count {
63
  return count;
64
}
65
@end
66
 
67
int main(void) {
68
  CHECK_IF(!strcmp ([@"Object" cString], getDesc()));
69
  CHECK_IF(!strcmp ([@"Array" cString], getDesc()));
70
 
71
  Array* a1 = [Array arrayWithObjects:@"One", @"Two", @"Three", nil];
72
  Array* a2 = [Array arrayWithObjects:@"Four", @"Five", nil];
73
 
74
  TestT t(7);
75
  CHECK_IF(t.abc(a1) + t.abc(a2) == 35);
76
  CHECK_IF(abc(a1, a2) * t.k == 35);
77
  return 0;
78
}
79
#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.