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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [template-4.mm] - Blame information for rev 703

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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