OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [obj-c++.dg/] [const-str-3.mm] - Blame information for rev 308

Details | Compare with Previous | View Log

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