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