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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [call-super-2.m] - Blame information for rev 713

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

Line No. Rev Author Line
1 704 jeremybenn
/* Check if casting 'self' or 'super' affects message lookup in the correct way.  */
2
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
3
/* { dg-do compile } */
4
 
5
#include "../objc-obj-c++-shared/TestsuiteObject.h"
6
#include "../objc-obj-c++-shared/runtime.h"
7
#include <stddef.h>
8
 
9
/* FIXME: This is temporary.  At the moment, the compiler, when
10
   compiling for the GNU runtime and doing method checks, only
11
   recognizes objc_get_class(), and not objc_getClass().  So
12
   temporarily force objc_get_class() to be used.  */
13
#ifndef __NEXT_RUNTIME__
14
# define objc_getClass(C) objc_get_class(C)
15
#endif
16
 
17
@protocol Func
18
+ (int) class_func0;
19
- (int) instance_func0;
20
@end
21
 
22
@interface Derived: TestsuiteObject
23
+ (int) class_func1;
24
+ (int) class_func2;
25
+ (int) class_func3;
26
+ (int) class_func4;
27
+ (int) class_func5;
28
+ (int) class_func6;
29
+ (int) class_func7;
30
- (int) instance_func1;
31
- (int) instance_func2;
32
- (int) instance_func3;
33
- (int) instance_func4;
34
- (int) instance_func5;
35
- (int) instance_func6;
36
- (int) instance_func7;
37
@end
38
 
39
@interface Derived (Categ)
40
+ (int) categ_class_func1;
41
+ (int) categ_class_func2;
42
- (int) categ_instance_func1;
43
- (int) categ_instance_func2;
44
@end
45
 
46
@implementation Derived
47
+ (int) class_func1
48
{
49
   int i = (size_t)[self class_func0];       /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
50
   return i + (size_t)[super class_func0];   /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
51
}
52
+ (int) class_func2
53
{
54
   int i = [(id <Func>)self class_func0];  /* { dg-warning ".\\-class_func0. not found in protocol" } */
55
   i += [(id <Func>)super class_func0];    /* { dg-warning ".\\-class_func0. not found in protocol" } */
56
   i += [(Class <Func>)self class_func0];
57
   return i + [(Class <Func>)super class_func0];
58
}
59
+ (int) class_func3
60
{
61
   return [(TestsuiteObject <Func> *)super class_func0];
62
}
63
+ (int) class_func4
64
{
65
   return [(Derived <Func> *)super class_func0];
66
}
67
+ (int) class_func5
68
{
69
   int i = (size_t)[Derived class_func0];    /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
70
   return i + (size_t)[TestsuiteObject class_func0];  /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
71
}
72
+ (int) class_func6
73
{
74
   return (size_t)[objc_getClass("TestsuiteObject") class_func1];  /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func1." } */
75
}
76
+ (int) class_func7
77
{
78
   return [objc_getClass("Derived") class_func1];
79
}
80
- (int) instance_func1
81
{
82
   int i = (size_t)[self instance_func0];     /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
83
   return i + (size_t)[super instance_func0]; /* { dg-warning ".TestsuiteObject. may not respond to .\\-instance_func0." } */
84
}
85
- (int) instance_func2
86
{
87
   return [(id <Func>)super instance_func0];
88
}
89
- (int) instance_func3
90
{
91
   return [(TestsuiteObject <Func> *)super instance_func0];
92
}
93
- (int) instance_func4
94
{
95
   return [(Derived <Func> *)super instance_func0];
96
}
97
- (int) instance_func5
98
{
99
   int i = (size_t)[Derived instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+instance_func1." } */
100
   return i + (size_t)[TestsuiteObject instance_func1]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+instance_func1." } */
101
}
102
- (int) instance_func6
103
{
104
   return (size_t)[objc_getClass("TestsuiteObject") class_func1]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func1." } */
105
}
106
- (int) instance_func7
107
{
108
   return [objc_getClass("Derived") class_func1];
109
}
110
@end
111
 
112
@implementation Derived (Categ)
113
+ (int) categ_class_func1
114
{
115
   int i = (size_t)[self class_func0];       /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
116
   i += [self class_func1];
117
   i += [self categ_class_func2];
118
   i += (size_t)[self categ_instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+categ_instance_func1." } */
119
   return i + (size_t)[super class_func0];   /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
120
}
121
+ (int) categ_class_func2
122
{
123
   int i = [(id <Func>)self class_func0];  /* { dg-warning ".\\-class_func0. not found in protocol" } */
124
   i += [(id <Func>)super class_func0];    /* { dg-warning ".\\-class_func0. not found in protocol" } */
125
   i += [(Class <Func>)self class_func0];
126
   return i + [(Class <Func>)super class_func0];
127
}
128
- (int) categ_instance_func1
129
{
130
   int i = (size_t)[self instance_func0];    /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
131
   i += [(Derived <Func> *)self categ_instance_func2];
132
   i += (size_t)[(TestsuiteObject <Func> *)self categ_instance_func2]; /* { dg-warning ".TestsuiteObject. may not respond to .\\-categ_instance_func2." } */
133
   /* { dg-warning ".\\-categ_instance_func2. not found in protocol" "" { target *-*-* } 132 } */
134
   i += (size_t)[(id <Func>)self categ_instance_func2];  /* { dg-warning ".\\-categ_instance_func2. not found in protocol" } */
135
   i += [(id)self categ_instance_func2];
136
   return i + (size_t)[super instance_func0];   /* { dg-warning ".TestsuiteObject. may not respond to .\\-instance_func0." } */
137
}
138
- (int) categ_instance_func2
139
{
140
   return [(id <Func>)super instance_func0];
141
}
142
@end
143
 
144
/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
145
/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
146
/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */

powered by: WebSVN 2.1.0

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