2 // { dg-require-weak "" }
3 // This test requires support for undefined weak symbols. This support
4 // is not available on hppa*-*-hpux*. The test is skipped rather than
5 // xfailed to suppress the warning that would otherwise arise.
6 // { dg-skip-if "" { "hppa*-*-hpux*" } "*" { "" } }
7 // { dg-options "-O2" }
8 // { dg-additional-sources "attr-weakref-1a.c" }
10 // Copyright 2005 Free Software Foundation, Inc.
11 // Contributed by Alexandre Oliva <aoliva@redhat.com>
13 // Torture test for weakrefs. The first letter of an identifier
14 // indicates whether/how it is defined; the second letter indicates
15 // whether it is part of a variable or function test; the number that
16 // follows is a test counter, and a letter that may follow enables
17 // multiple identifiers within the same test (e.g., multiple weakrefs
18 // or pointers to the same identifier).
20 // Identifiers starting with W are weakrefs; those with p are
21 // pointers; those with g are global definitions; those with l are
22 // local definitions; those with w are expected to be weak undefined
23 // in the symbol table; those with u are expected to be marked as
24 // non-weak undefined in the symbol table.
28 #define USED __attribute__((used))
33 extern vtype Wv1a
__attribute__((weakref ("wv1")));
34 static vtype
*pv1a USED
= &Wv1a
;
35 extern vtype Wv1b
__attribute__((weak
, weakref
, alias ("wv1")));
36 static vtype
*pv1b USED
= &Wv1b
;
37 extern vtype Wv1c
__attribute__((weakref
));
38 extern vtype Wv1c
__attribute__((alias ("wv1")));
39 static vtype
*pv1c USED
= &Wv1c
;
42 extern vtype Wv2a
__attribute__((weakref ("gv2")));
43 static vtype
*pv2a USED
= &Wv2a
;
46 extern vtype Wv3a
__attribute__((weakref ("lv3")));
47 static vtype
*pv3a USED
= &Wv3a
;
50 extern vtype Wv4a
__attribute__((weakref ("uv4")));
51 static vtype
*pv4a USED
= &Wv4a
;
52 static vtype
*pv4 USED
= &uv4
;
54 extern vtype Wv5a
__attribute__((weakref ("uv5")));
55 static vtype
*pv5a USED
= &Wv5a
;
57 static vtype
*pv5 USED
= &uv5
;
59 extern vtype Wv6a
__attribute__((weakref ("wv6")));
60 static vtype
*pv6a USED
= &Wv6a
;
63 extern vtype Wv7a
__attribute__((weakref ("uv7")));
64 static vtype
* USED
fv7 (void) {
68 static vtype
* USED
fv7a (void) {
73 static vtype
* USED
fv8a (void) {
76 extern vtype Wv8a
__attribute__((weakref ("uv8")));
77 static vtype
* USED
fv8 (void) {
81 extern vtype wv9
__attribute__((weak
));
82 extern vtype Wv9a
__attribute__((weakref ("wv9")));
83 static vtype
*pv9a USED
= &Wv9a
;
85 extern vtype Wv10a
__attribute__((weakref ("Wv10b")));
86 extern vtype Wv10b
__attribute__((weakref ("Wv10c")));
87 extern vtype Wv10c
__attribute__((weakref ("Wv10d")));
88 extern vtype Wv10d
__attribute__((weakref ("wv10")));
92 extern vtype Wv11d
__attribute__((weakref ("wv11")));
93 extern vtype Wv11c
__attribute__((weakref ("Wv11d")));
94 extern vtype Wv11b
__attribute__((weakref ("Wv11c")));
95 extern vtype Wv11a
__attribute__((weakref ("Wv11b")));
97 extern vtype Wv12
__attribute__((weakref ("wv12")));
98 extern vtype wv12
__attribute__((weak
));
100 extern vtype Wv13
__attribute__((weakref ("wv13")));
101 extern vtype wv13
__attribute__((weak
));
103 extern vtype Wv14a
__attribute__((weakref ("wv14")));
104 extern vtype Wv14b
__attribute__((weakref ("wv14")));
105 extern vtype wv14
__attribute__((weak
));
107 typedef void ftype(void);
110 extern ftype Wf1a
__attribute__((weakref ("wf1")));
111 static ftype
*pf1a USED
= &Wf1a
;
112 extern ftype Wf1b
__attribute__((weak
, weakref
, alias ("wf1")));
113 static ftype
*pf1b USED
= &Wf1b
;
114 extern ftype Wf1c
__attribute__((weakref
));
115 extern ftype Wf1c
__attribute__((alias ("wf1")));
116 static ftype
*pf1c USED
= &Wf1c
;
119 extern ftype Wf2a
__attribute__((weakref ("gf2")));
120 static ftype
*pf2a USED
= &Wf2a
;
122 static void lf3(void) {}
123 extern ftype Wf3a
__attribute__((weakref ("lf3")));
124 static ftype
*pf3a USED
= &Wf3a
;
127 extern ftype Wf4a
__attribute__((weakref ("uf4")));
128 static ftype
*pf4a USED
= &Wf4a
;
129 static ftype
*pf4 USED
= &uf4
;
131 extern ftype Wf5a
__attribute__((weakref ("uf5")));
132 static ftype
*pf5a USED
= &Wf5a
;
134 static ftype
*pf5 USED
= &uf5
;
136 extern ftype Wf6a
__attribute__((weakref ("wf6")));
137 static ftype
*pf6a USED
= &Wf6a
;
140 extern ftype Wf7a
__attribute__((weakref ("uf7")));
141 static ftype
* USED
ff7 (void) {
145 static ftype
* USED
ff7a (void) {
150 static ftype
* USED
ff8a (void) {
153 extern ftype Wf8a
__attribute__((weakref ("uf8")));
154 static ftype
* USED
ff8 (void) {
158 extern ftype wf9
__attribute__((weak
));
159 extern ftype Wf9a
__attribute__((weakref ("wf9")));
160 static ftype
*pf9a USED
= &Wf9a
;
162 extern ftype Wf10a
__attribute__((weakref ("Wf10b")));
163 extern ftype Wf10b
__attribute__((weakref ("Wf10c")));
164 extern ftype Wf10c
__attribute__((weakref ("Wf10d")));
165 extern ftype Wf10d
__attribute__((weakref ("wf10")));
169 extern ftype Wf11d
__attribute__((weakref ("wf11")));
170 extern ftype Wf11c
__attribute__((weakref ("Wf11d")));
171 extern ftype Wf11b
__attribute__((weakref ("Wf11c")));
172 extern ftype Wf11a
__attribute__((weakref ("Wf11b")));
174 extern ftype Wf12
__attribute__((weakref ("wf12")));
175 extern ftype wf12
__attribute__((weak
));
177 extern ftype Wf13
__attribute__((weakref ("wf13")));
178 extern ftype wf13
__attribute__((weak
));
180 extern ftype Wf14a
__attribute__((weakref ("wf14")));
181 extern ftype Wf14b
__attribute__((weakref ("wf14")));
182 extern ftype wf14
__attribute__((weak
));
184 #define chk(p) do { if (!p) abort (); } while (0)