1 // { dg-do run { target { *-*-darwin* } } }
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" }
7 // Copyright 2005 Free Software Foundation, Inc.
8 // Contributed by Alexandre Oliva <aoliva@redhat.com>
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).
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.
25 #define USED __attribute__((used))
30 static vtype Wv1a
__attribute__((weakref ("wv1")));
31 static vtype
*pv1a USED
= &Wv1a
;
34 static vtype Wv2a
__attribute__((weakref ("gv2")));
35 static vtype
*pv2a USED
= &Wv2a
;
38 static vtype Wv3a
__attribute__((weakref ("lv3")));
39 static vtype
*pv3a USED
= &Wv3a
;
42 static vtype Wv4a
__attribute__((weakref ("uv4")));
43 static vtype
*pv4a USED
= &Wv4a
;
44 static vtype
*pv4 USED
= &uv4
;
46 static vtype Wv5a
__attribute__((weakref ("uv5")));
47 static vtype
*pv5a USED
= &Wv5a
;
49 static vtype
*pv5 USED
= &uv5
;
51 static vtype Wv6a
__attribute__((weakref ("wv6")));
52 static vtype
*pv6a USED
= &Wv6a
;
55 static vtype Wv7a
__attribute__((weakref ("uv7")));
56 static vtype
* USED
fv7 (void) {
60 static vtype
* USED
fv7a (void) {
65 static vtype
* USED
fv8a (void) {
68 static vtype Wv8a
__attribute__((weakref ("uv8")));
69 static vtype
* USED
fv8 (void) {
73 extern vtype wv9
__attribute__((weak
));
74 static vtype Wv9a
__attribute__((weakref ("wv9")));
75 static vtype
*pv9a USED
= &Wv9a
;
77 static vtype Wv10a
__attribute__((weakref ("Wv10b")));
78 static vtype Wv10b
__attribute__((weakref ("Wv10c")));
79 static vtype Wv10c
__attribute__((weakref ("Wv10d")));
80 static vtype Wv10d
__attribute__((weakref ("wv10")));
84 static vtype Wv11d
__attribute__((weakref ("wv11")));
85 static vtype Wv11c
__attribute__((weakref ("Wv11d")));
86 static vtype Wv11b
__attribute__((weakref ("Wv11c")));
87 static vtype Wv11a
__attribute__((weakref ("Wv11b")));
89 static vtype Wv12
__attribute__((weakref ("wv12")));
90 extern vtype wv12
__attribute__((weak
));
92 static vtype Wv13
__attribute__((weakref ("wv13")));
93 extern vtype wv13
__attribute__((weak
));
95 static vtype Wv14a
__attribute__((weakref ("wv14")));
96 static vtype Wv14b
__attribute__((weakref ("wv14")));
97 extern vtype wv14
__attribute__((weak
));
99 typedef void ftype(void);
102 static ftype Wf1a
__attribute__((weakref ("wf1")));
103 static ftype
*pf1a USED
= &Wf1a
;
104 static ftype Wf1c
__attribute__((weakref
));
105 extern ftype Wf1c
__attribute__((alias ("wf1")));
106 static ftype
*pf1c USED
= &Wf1c
;
109 static ftype Wf2a
__attribute__((weakref ("gf2")));
110 static ftype
*pf2a USED
= &Wf2a
;
112 static void lf3(void) {}
113 static ftype Wf3a
__attribute__((weakref ("lf3")));
114 static ftype
*pf3a USED
= &Wf3a
;
117 static ftype Wf4a
__attribute__((weakref ("uf4")));
118 static ftype
*pf4a USED
= &Wf4a
;
119 static ftype
*pf4 USED
= &uf4
;
121 static ftype Wf5a
__attribute__((weakref ("uf5")));
122 static ftype
*pf5a USED
= &Wf5a
;
124 static ftype
*pf5 USED
= &uf5
;
126 static ftype Wf6a
__attribute__((weakref ("wf6")));
127 static ftype
*pf6a USED
= &Wf6a
;
130 static ftype Wf7a
__attribute__((weakref ("uf7")));
131 static ftype
* USED
ff7 (void) {
135 static ftype
* USED
ff7a (void) {
140 static ftype
* USED
ff8a (void) {
143 static ftype Wf8a
__attribute__((weakref ("uf8")));
144 static ftype
* USED
ff8 (void) {
148 extern ftype wf9
__attribute__((weak
));
149 static ftype Wf9a
__attribute__((weakref ("wf9")));
150 static ftype
*pf9a USED
= &Wf9a
;
152 static ftype Wf10a
__attribute__((weakref ("Wf10b")));
153 static ftype Wf10b
__attribute__((weakref ("Wf10c")));
154 static ftype Wf10c
__attribute__((weakref ("Wf10d")));
155 static ftype Wf10d
__attribute__((weakref ("wf10")));
159 static ftype Wf11d
__attribute__((weakref ("wf11")));
160 static ftype Wf11c
__attribute__((weakref ("Wf11d")));
161 static ftype Wf11b
__attribute__((weakref ("Wf11c")));
162 static ftype Wf11a
__attribute__((weakref ("Wf11b")));
164 static ftype Wf12
__attribute__((weakref ("wf12")));
165 extern ftype wf12
__attribute__((weak
));
167 static ftype Wf13
__attribute__((weakref ("wf13")));
168 extern ftype wf13
__attribute__((weak
));
170 static ftype Wf14a
__attribute__((weakref ("wf14")));
171 static ftype Wf14b
__attribute__((weakref ("wf14")));
172 extern ftype wf14
__attribute__((weak
));
175 #define chk(p) do { if (!p) abort (); } while (0)