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/] [execute/] [bycopy-3.m] - Blame information for rev 307

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 307 jeremybenn
/*
2
 * Contributed by Nicola Pero <nicola@brainstorm.co.uk>
3
 * Wed Feb 28 12:27:03 CET 2001
4
 */
5
 
6
/*
7
 * This test contains some no-op code which is needed to keep it
8
 * compile on broken gcc 3.x.  Anyway, the no-op code does not
9
 * interfere with what we are testing, which is that the `bycopy'
10
 * keyword generates the _F_BYCOPY qualifier for the return type.  */
11
 
12
#include "../../objc-obj-c++-shared/next-mapping.h"
13
#include "../../objc-obj-c++-shared/Protocol1.h"
14
 
15
#ifndef __NEXT_RUNTIME__
16
#include <objc/encoding.h>
17
#endif
18
 
19
@protocol MyProtocol
20
+ (bycopy id<MyProtocol>) bycopyMethod;
21
@end
22
 
23
/* This no-op class to keep it compile under broken gcc 3.x */
24
@interface MyObject : Object <MyProtocol>
25
@end
26
 
27
@implementation MyObject
28
+ (bycopy id<MyProtocol>) bycopyMethod
29
{
30
  return [MyObject alloc];
31
}
32
@end
33
 
34
int main (void)
35
{
36
  struct objc_method_description *method;
37
  const char *method_types;
38
  unsigned qualifiers;
39
  Protocol *protocol;
40
  /* This no-op command is needed to keep the test compile on broken
41
     gcc 3.x */
42
  MyObject *object = [MyObject bycopyMethod];
43
 
44
  /* Get the protocol object */
45
  protocol = @protocol (MyProtocol);
46
 
47
  /* Ask to the protocol for the description of the method bycopyMethod */
48
  method = [protocol descriptionForClassMethod: @selector (bycopyMethod)];
49
  if (method == NULL)
50
    {
51
      printf ("Could not find method bycopyMethod in protocol!\n");
52
      exit (1);
53
    }
54
 
55
  /* Get the method types for the method - which encode return type,
56
     arguments etc. */
57
  method_types = method->types;
58
 
59
  /* Get the qualifiers for the return type */
60
  qualifiers = objc_get_type_qualifiers (method_types);
61
 
62
  /* If _F_BYCOPY is not there, the compiler is broken */
63
  if (! (qualifiers & _F_BYCOPY))
64
    {
65
      printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n");
66
      exit (1);
67
    }
68
 
69
  /* Else, happy end */
70
  return 0;
71
}

powered by: WebSVN 2.1.0

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