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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc.dg/] [const-str-3.m] - Blame information for rev 315

Go to most recent revision | Details | Compare with Previous | View Log

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