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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [attr-weakref-1.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
// { dg-do run }
2
// { dg-require-weak "" }
3
// On darwin, we use attr-weakref-1-darwin.c.
4
// This test requires support for undefined weak symbols.  This support
5
// is not available on alpha*-dec-osf* and hppa*-*-hpux*.  The test is
6
// skipped rather than xfailed to suppress the warning that would otherwise
7
// arise.
8
// { dg-skip-if "" { "alpha*-dec-osf*" "*-*-darwin*" "hppa*-*-hpux*" } "*" { "" } }
9
// For kernel modules and static RTPs, the loader treats undefined weak
10
// symbols in the same way as undefined strong symbols.  The test
11
// therefore fails to load, so skip it.
12
// { dg-skip-if "" { "*-*-vxworks*" && nonpic } "*" { "-non-static" } }
13
// { dg-options "-O2" }
14
// { dg-additional-sources "attr-weakref-1a.c" }
15
 
16
// Copyright 2005 Free Software Foundation, Inc.
17
// Contributed by Alexandre Oliva <aoliva@redhat.com>
18
 
19
// Torture test for weakrefs.  The first letter of an identifier
20
// indicates whether/how it is defined; the second letter indicates
21
// whether it is part of a variable or function test; the number that
22
// follows is a test counter, and a letter that may follow enables
23
// multiple identifiers within the same test (e.g., multiple weakrefs
24
// or pointers to the same identifier).
25
 
26
// Identifiers starting with W are weakrefs; those with p are
27
// pointers; those with g are global definitions; those with l are
28
// local definitions; those with w are expected to be weak undefined
29
// in the symbol table; those with u are expected to be marked as
30
// non-weak undefined in the symbol table.
31
 
32
#include <stdlib.h>
33
 
34
#define USED __attribute__((used))
35
 
36
typedef int vtype;
37
 
38
extern vtype wv1;
39
static vtype Wv1a __attribute__((weakref ("wv1")));
40
static vtype *pv1a USED = &Wv1a;
41
 
42
vtype gv2;
43
static vtype Wv2a __attribute__((weakref ("gv2")));
44
static vtype *pv2a USED = &Wv2a;
45
 
46
static vtype lv3;
47
static vtype Wv3a __attribute__((weakref ("lv3")));
48
static vtype *pv3a USED = &Wv3a;
49
 
50
extern vtype uv4;
51
static vtype Wv4a __attribute__((weakref ("uv4")));
52
static vtype *pv4a USED = &Wv4a;
53
static vtype *pv4 USED = &uv4;
54
 
55
static vtype Wv5a __attribute__((weakref ("uv5")));
56
static vtype *pv5a USED = &Wv5a;
57
extern vtype uv5;
58
static vtype *pv5 USED = &uv5;
59
 
60
static vtype Wv6a __attribute__((weakref ("wv6")));
61
static vtype *pv6a USED = &Wv6a;
62
extern vtype wv6;
63
 
64
static vtype Wv7a __attribute__((weakref ("uv7")));
65
static vtype* USED fv7 (void) {
66
  return &Wv7a;
67
}
68
extern vtype uv7;
69
static vtype* USED fv7a (void) {
70
  return &uv7;
71
}
72
 
73
extern vtype uv8;
74
static vtype* USED fv8a (void) {
75
  return &uv8;
76
}
77
static vtype Wv8a __attribute__((weakref ("uv8")));
78
static vtype* USED fv8 (void) {
79
  return &Wv8a;
80
}
81
 
82
extern vtype wv9 __attribute__((weak));
83
static vtype Wv9a __attribute__((weakref ("wv9")));
84
static vtype *pv9a USED = &Wv9a;
85
 
86
static vtype Wv10a __attribute__((weakref ("Wv10b")));
87
static vtype Wv10b __attribute__((weakref ("Wv10c")));
88
static vtype Wv10c __attribute__((weakref ("Wv10d")));
89
static vtype Wv10d __attribute__((weakref ("wv10")));
90
extern vtype wv10;
91
 
92
extern vtype wv11;
93
static vtype Wv11d __attribute__((weakref ("wv11")));
94
static vtype Wv11c __attribute__((weakref ("Wv11d")));
95
static vtype Wv11b __attribute__((weakref ("Wv11c")));
96
static vtype Wv11a __attribute__((weakref ("Wv11b")));
97
 
98
static vtype Wv12 __attribute__((weakref ("wv12")));
99
extern vtype wv12 __attribute__((weak));
100
 
101
static vtype Wv13 __attribute__((weakref ("wv13")));
102
extern vtype wv13 __attribute__((weak));
103
 
104
static vtype Wv14a __attribute__((weakref ("wv14")));
105
static vtype Wv14b __attribute__((weakref ("wv14")));
106
extern vtype wv14 __attribute__((weak));
107
 
108
typedef void ftype(void);
109
 
110
extern ftype wf1;
111
static ftype Wf1a __attribute__((weakref ("wf1")));
112
static ftype *pf1a USED = &Wf1a;
113
static ftype Wf1c __attribute__((weakref));
114
extern ftype Wf1c __attribute__((alias ("wf1")));
115
static ftype *pf1c USED = &Wf1c;
116
 
117
void gf2(void) {}
118
static ftype Wf2a __attribute__((weakref ("gf2")));
119
static ftype *pf2a USED = &Wf2a;
120
 
121
static void lf3(void) {}
122
static ftype Wf3a __attribute__((weakref ("lf3")));
123
static ftype *pf3a USED = &Wf3a;
124
 
125
extern ftype uf4;
126
static ftype Wf4a __attribute__((weakref ("uf4")));
127
static ftype *pf4a USED = &Wf4a;
128
static ftype *pf4 USED = &uf4;
129
 
130
static ftype Wf5a __attribute__((weakref ("uf5")));
131
static ftype *pf5a USED = &Wf5a;
132
extern ftype uf5;
133
static ftype *pf5 USED = &uf5;
134
 
135
static ftype Wf6a __attribute__((weakref ("wf6")));
136
static ftype *pf6a USED = &Wf6a;
137
extern ftype wf6;
138
 
139
static ftype Wf7a __attribute__((weakref ("uf7")));
140
static ftype* USED ff7 (void) {
141
  return &Wf7a;
142
}
143
extern ftype uf7;
144
static ftype* USED ff7a (void) {
145
  return &uf7;
146
}
147
 
148
extern ftype uf8;
149
static ftype* USED ff8a (void) {
150
  return &uf8;
151
}
152
static ftype Wf8a __attribute__((weakref ("uf8")));
153
static ftype* USED ff8 (void) {
154
  return &Wf8a;
155
}
156
 
157
extern ftype wf9 __attribute__((weak));
158
static ftype Wf9a __attribute__((weakref ("wf9")));
159
static ftype *pf9a USED = &Wf9a;
160
 
161
static ftype Wf10a __attribute__((weakref ("Wf10b")));
162
static ftype Wf10b __attribute__((weakref ("Wf10c")));
163
static ftype Wf10c __attribute__((weakref ("Wf10d")));
164
static ftype Wf10d __attribute__((weakref ("wf10")));
165
extern ftype wf10;
166
 
167
extern ftype wf11;
168
static ftype Wf11d __attribute__((weakref ("wf11")));
169
static ftype Wf11c __attribute__((weakref ("Wf11d")));
170
static ftype Wf11b __attribute__((weakref ("Wf11c")));
171
static ftype Wf11a __attribute__((weakref ("Wf11b")));
172
 
173
static ftype Wf12 __attribute__((weakref ("wf12")));
174
extern ftype wf12 __attribute__((weak));
175
 
176
static ftype Wf13 __attribute__((weakref ("wf13")));
177
extern ftype wf13 __attribute__((weak));
178
 
179
static ftype Wf14a __attribute__((weakref ("wf14")));
180
static ftype Wf14b __attribute__((weakref ("wf14")));
181
extern ftype wf14 __attribute__((weak));
182
 
183
#ifndef __APPLE__
184
#define chk(p) do { if (!p) abort (); } while (0)
185
#else
186
#define chk(p) /* */
187
#endif
188
 
189
int main () {
190
  chk (!pv1a);
191
  chk (pv2a);
192
  chk (pv3a);
193
  chk (pv4a);
194
  chk (pv4);
195
  chk (pv5a);
196
  chk (pv5);
197
  chk (!pv6a);
198
  chk (fv7 ());
199
  chk (fv7a ());
200
  chk (fv8 ());
201
  chk (fv8a ());
202
  chk (!pv9a);
203
  chk (!&Wv10a);
204
  chk (!&Wv11a);
205
  chk (!&Wv12);
206
  chk (!&wv12);
207
  chk (!&wv13);
208
  chk (!&Wv14a);
209
 
210
  chk (!pf1a);
211
  chk (!pf1c);
212
  chk (pf2a);
213
  chk (pf3a);
214
  chk (pf4a);
215
  chk (pf4);
216
  chk (pf5a);
217
  chk (pf5);
218
  chk (!pf6a);
219
  chk (ff7 ());
220
  chk (ff7a ());
221
  chk (ff8 ());
222
  chk (ff8a ());
223
  chk (!pf9a);
224
  chk (!&Wf10a);
225
  chk (!&Wf11a);
226
  chk (!&Wf12);
227
  chk (!&wf12);
228
  chk (!&wf13);
229
  chk (!&Wf14a);
230
 
231
  exit (0);
232
}

powered by: WebSVN 2.1.0

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