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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc.dg/] [call-super-2.m] - Blame information for rev 827

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

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