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