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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [torture/] [strings/] [const-str-3.mm] - Blame information for rev 703

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Test the -fconstant-string-class=Foo option under the NeXT
2
   runtime.  */
3
/* Developed by Markus Hitter .  */
4
 
5
/* { dg-do run { target *-*-darwin* } } */
6
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
7
/* { dg-options "-fconstant-string-class=Foo" } */
8
/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
9
 
10
#include "../../../objc-obj-c++-shared/objc-test-suite-types.h"
11
 
12
#include 
13
#include 
14
#include 
15
 
16
@interface Foo {
17
  void *dummy_class_ref;
18
  char *cString;
19
  unsigned int len;
20
}
21
+ initialize;
22
- (char *)customString;
23
@end
24
 
25
TNS_STRING_REF_T _FooClassReference; /* Only used by NeXT.  */
26
 
27
@implementation Foo
28
+ initialize {return self;}
29
- (char *)customString {
30
  return cString;
31
}
32
@end
33
 
34
int main () {
35
  Foo *string = @"bla";
36
  Foo *string2 = @"bla";
37
 
38
  if(string != string2)
39
    abort();
40
  printf("Strings are being uniqued properly\n");
41
 
42
#ifdef __NEXT_RUNTIME__
43
  /* This memcpy has to be done before the first message is sent to a
44
     constant string object. Can't be moved to +initialize since _that_
45
     is already a message. */
46
 
47
  memcpy(&_FooClassReference, objc_getClass("Foo"), sizeof(_FooClassReference));
48
#endif
49
 
50
  if (strcmp ([string customString], "bla")) {
51
    abort ();
52
  }
53
 
54
  printf([@"This is a working constant string object\n" customString]);
55
  return 0;
56
}
57
 

powered by: WebSVN 2.1.0

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