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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [obj-c++.dg/] [const-str-3.mm] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Test the -fconstant-string-class=Foo option under the NeXT
2
   runtime.  */
3
/* Developed by Markus Hitter .  */
4
 
5
/* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
6
/* { dg-do run { target *-*-darwin* } } */
7
 
8
#include 
9
#include 
10
#include 
11
#include 
12
#include 
13
 
14
@interface Foo: Object {
15
  char *cString;
16
  unsigned int len;
17
}
18
- (char *)customString;
19
@end
20
 
21
struct objc_class _FooClassReference;
22
 
23
@implementation Foo : Object
24
- (char *)customString {
25
  return cString;
26
}
27
@end
28
 
29
int main () {
30
  Foo *string = @"bla";
31
  Foo *string2 = @"bla";
32
 
33
  if(string != string2)
34
    abort();
35
  printf("Strings are being uniqued properly\n");
36
 
37
  /* This memcpy has to be done before the first message is sent to a
38
     constant string object. Can't be moved to +initialize since _that_
39
     is already a message. */
40
 
41
  memcpy(&_FooClassReference, objc_getClass("Foo"), sizeof(_FooClassReference));
42
  if (strcmp ([string customString], "bla")) {
43
    abort ();
44
  }
45
 
46
  printf([@"This is a working constant string object\n" customString]);
47
  return 0;
48
}

powered by: WebSVN 2.1.0

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