summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/attr-weakref-1.c
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-05 20:38:37 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-05 20:38:37 +0000
commit0a3ecdc147a6b04d40d0638f979612644696cdf9 (patch)
tree5e7f04633347fa5f7ca0e1b9e1b991f1227bdea4 /gcc/testsuite/gcc.dg/attr-weakref-1.c
parent91732c81f7e2e48b413e0b41c0ec0c6f33d03318 (diff)
downloadgcc-0a3ecdc147a6b04d40d0638f979612644696cdf9.tar.gz
Index: gcc/ChangeLog
2005-12-05 Geoffrey Keating <geoffk@apple.com> * varasm.c (default_binds_local_p_1): Weakrefs don't bind locally. A hidden weak object does bind locally. Strong linkonce data counts like any other strong symbol for binding. (weak_finish_1): Don't specially handle weakrefs, they no longer arrive here. (assemble_alias): Weakrefs can't be TREE_PUBLIC yet. * c-common.c (handle_alias_attribute): Allow static aliases of variables. (handle_weakref_attribute): Don't call declare_weak on weakrefs. * gthr-dce.h: Make weakrefs static. * gthr-tpf.h: Likewise. * gthr-solaris.h: Likewise. * gthr-posix.h: Likewise. * gthr-posix95.h: Likewise. * config/darwin.c (darwin_encode_section_info): static weakref variables are not necessarily defined in this translation unit. * doc/extend.texi (Function Attributes): Mention that an alias attribute creates a definition for the thing it's attached to. Change the documentation for weakref to say that the thing it's attached to must be static. Index: gcc/testsuite/ChangeLog 2005-12-05 Geoffrey Keating <geoffk@apple.com> * g++.old-deja/g++.abi/vtable2.C: Make weakrefs static. * gcc.dg/attr-weakref-1.c: Modify to not try to test public weakrefs, and to work on Darwin. * gcc.dg/attr-weakref-1b.c: New file. * gcc.dg/attr-weakref-2.c: New test. * gcc.dg/darwin-weakref-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108074 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/attr-weakref-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/attr-weakref-1.c102
1 files changed, 49 insertions, 53 deletions
diff --git a/gcc/testsuite/gcc.dg/attr-weakref-1.c b/gcc/testsuite/gcc.dg/attr-weakref-1.c
index c47ce1e569b..7ffd64d55ca 100644
--- a/gcc/testsuite/gcc.dg/attr-weakref-1.c
+++ b/gcc/testsuite/gcc.dg/attr-weakref-1.c
@@ -1,7 +1,9 @@
// { dg-do run }
// { dg-require-weak "" }
// { dg-options "-O2" }
+// { dg-options "-O2 -mmacosx-version-min=10.2" { target { powerpc-*-darwin* } } }
// { dg-additional-sources "attr-weakref-1a.c" }
+// { dg-additional-sources "attr-weakref-1a.c attr-weakref-1b.c" { target { *-*-darwin* } } }
// Copyright 2005 Free Software Foundation, Inc.
// Contributed by Alexandre Oliva <aoliva@redhat.com>
@@ -26,37 +28,32 @@
typedef int vtype;
extern vtype wv1;
-extern vtype Wv1a __attribute__((weakref ("wv1")));
+static vtype Wv1a __attribute__((weakref ("wv1")));
static vtype *pv1a USED = &Wv1a;
-extern vtype Wv1b __attribute__((weak, weakref, alias ("wv1")));
-static vtype *pv1b USED = &Wv1b;
-extern vtype Wv1c __attribute__((weakref));
-extern vtype Wv1c __attribute__((alias ("wv1")));
-static vtype *pv1c USED = &Wv1c;
vtype gv2;
-extern vtype Wv2a __attribute__((weakref ("gv2")));
+static vtype Wv2a __attribute__((weakref ("gv2")));
static vtype *pv2a USED = &Wv2a;
static vtype lv3;
-extern vtype Wv3a __attribute__((weakref ("lv3")));
+static vtype Wv3a __attribute__((weakref ("lv3")));
static vtype *pv3a USED = &Wv3a;
extern vtype uv4;
-extern vtype Wv4a __attribute__((weakref ("uv4")));
+static vtype Wv4a __attribute__((weakref ("uv4")));
static vtype *pv4a USED = &Wv4a;
static vtype *pv4 USED = &uv4;
-extern vtype Wv5a __attribute__((weakref ("uv5")));
+static vtype Wv5a __attribute__((weakref ("uv5")));
static vtype *pv5a USED = &Wv5a;
extern vtype uv5;
static vtype *pv5 USED = &uv5;
-extern vtype Wv6a __attribute__((weakref ("wv6")));
+static vtype Wv6a __attribute__((weakref ("wv6")));
static vtype *pv6a USED = &Wv6a;
extern vtype wv6;
-extern vtype Wv7a __attribute__((weakref ("uv7")));
+static vtype Wv7a __attribute__((weakref ("uv7")));
static vtype* USED fv7 (void) {
return &Wv7a;
}
@@ -69,71 +66,69 @@ extern vtype uv8;
static vtype* USED fv8a (void) {
return &uv8;
}
-extern vtype Wv8a __attribute__((weakref ("uv8")));
+static vtype Wv8a __attribute__((weakref ("uv8")));
static vtype* USED fv8 (void) {
return &Wv8a;
}
extern vtype wv9 __attribute__((weak));
-extern vtype Wv9a __attribute__((weakref ("wv9")));
+static vtype Wv9a __attribute__((weakref ("wv9")));
static vtype *pv9a USED = &Wv9a;
-extern vtype Wv10a __attribute__((weakref ("Wv10b")));
-extern vtype Wv10b __attribute__((weakref ("Wv10c")));
-extern vtype Wv10c __attribute__((weakref ("Wv10d")));
-extern vtype Wv10d __attribute__((weakref ("wv10")));
+static vtype Wv10a __attribute__((weakref ("Wv10b")));
+static vtype Wv10b __attribute__((weakref ("Wv10c")));
+static vtype Wv10c __attribute__((weakref ("Wv10d")));
+static vtype Wv10d __attribute__((weakref ("wv10")));
extern vtype wv10;
extern vtype wv11;
-extern vtype Wv11d __attribute__((weakref ("wv11")));
-extern vtype Wv11c __attribute__((weakref ("Wv11d")));
-extern vtype Wv11b __attribute__((weakref ("Wv11c")));
-extern vtype Wv11a __attribute__((weakref ("Wv11b")));
+static vtype Wv11d __attribute__((weakref ("wv11")));
+static vtype Wv11c __attribute__((weakref ("Wv11d")));
+static vtype Wv11b __attribute__((weakref ("Wv11c")));
+static vtype Wv11a __attribute__((weakref ("Wv11b")));
-extern vtype Wv12 __attribute__((weakref ("wv12")));
+static vtype Wv12 __attribute__((weakref ("wv12")));
extern vtype wv12 __attribute__((weak));
-extern vtype Wv13 __attribute__((weakref ("wv13")));
+static vtype Wv13 __attribute__((weakref ("wv13")));
extern vtype wv13 __attribute__((weak));
-extern vtype Wv14a __attribute__((weakref ("wv14")));
-extern vtype Wv14b __attribute__((weakref ("wv14")));
+static vtype Wv14a __attribute__((weakref ("wv14")));
+static vtype Wv14b __attribute__((weakref ("wv14")));
extern vtype wv14 __attribute__((weak));
typedef void ftype(void);
extern ftype wf1;
-extern ftype Wf1a __attribute__((weakref ("wf1")));
+static ftype Wf1a __attribute__((weakref ("wf1")));
static ftype *pf1a USED = &Wf1a;
-extern ftype Wf1b __attribute__((weak, weakref, alias ("wf1")));
-static ftype *pf1b USED = &Wf1b;
-extern ftype Wf1c __attribute__((weakref));
+static ftype Wf1c __attribute__((weakref));
extern ftype Wf1c __attribute__((alias ("wf1")));
static ftype *pf1c USED = &Wf1c;
void gf2(void) {}
-extern ftype Wf2a __attribute__((weakref ("gf2")));
+static ftype Wf2a __attribute__((weakref ("gf2")));
static ftype *pf2a USED = &Wf2a;
static void lf3(void) {}
-extern ftype Wf3a __attribute__((weakref ("lf3")));
+static ftype Wf3a __attribute__((weakref ("lf3")));
static ftype *pf3a USED = &Wf3a;
extern ftype uf4;
-extern ftype Wf4a __attribute__((weakref ("uf4")));
+static ftype Wf4a __attribute__((weakref ("uf4")));
static ftype *pf4a USED = &Wf4a;
static ftype *pf4 USED = &uf4;
-extern ftype Wf5a __attribute__((weakref ("uf5")));
+static ftype Wf5a __attribute__((weakref ("uf5")));
static ftype *pf5a USED = &Wf5a;
extern ftype uf5;
static ftype *pf5 USED = &uf5;
-extern ftype Wf6a __attribute__((weakref ("wf6")));
+static ftype Wf6a __attribute__((weakref ("wf6")));
static ftype *pf6a USED = &Wf6a;
extern ftype wf6;
-extern ftype Wf7a __attribute__((weakref ("uf7")));
+static ftype Wf7a __attribute__((weakref ("uf7")));
static ftype* USED ff7 (void) {
return &Wf7a;
}
@@ -146,43 +141,45 @@ extern ftype uf8;
static ftype* USED ff8a (void) {
return &uf8;
}
-extern ftype Wf8a __attribute__((weakref ("uf8")));
+static ftype Wf8a __attribute__((weakref ("uf8")));
static ftype* USED ff8 (void) {
return &Wf8a;
}
extern ftype wf9 __attribute__((weak));
-extern ftype Wf9a __attribute__((weakref ("wf9")));
+static ftype Wf9a __attribute__((weakref ("wf9")));
static ftype *pf9a USED = &Wf9a;
-extern ftype Wf10a __attribute__((weakref ("Wf10b")));
-extern ftype Wf10b __attribute__((weakref ("Wf10c")));
-extern ftype Wf10c __attribute__((weakref ("Wf10d")));
-extern ftype Wf10d __attribute__((weakref ("wf10")));
+static ftype Wf10a __attribute__((weakref ("Wf10b")));
+static ftype Wf10b __attribute__((weakref ("Wf10c")));
+static ftype Wf10c __attribute__((weakref ("Wf10d")));
+static ftype Wf10d __attribute__((weakref ("wf10")));
extern ftype wf10;
extern ftype wf11;
-extern ftype Wf11d __attribute__((weakref ("wf11")));
-extern ftype Wf11c __attribute__((weakref ("Wf11d")));
-extern ftype Wf11b __attribute__((weakref ("Wf11c")));
-extern ftype Wf11a __attribute__((weakref ("Wf11b")));
+static ftype Wf11d __attribute__((weakref ("wf11")));
+static ftype Wf11c __attribute__((weakref ("Wf11d")));
+static ftype Wf11b __attribute__((weakref ("Wf11c")));
+static ftype Wf11a __attribute__((weakref ("Wf11b")));
-extern ftype Wf12 __attribute__((weakref ("wf12")));
+static ftype Wf12 __attribute__((weakref ("wf12")));
extern ftype wf12 __attribute__((weak));
-extern ftype Wf13 __attribute__((weakref ("wf13")));
+static ftype Wf13 __attribute__((weakref ("wf13")));
extern ftype wf13 __attribute__((weak));
-extern ftype Wf14a __attribute__((weakref ("wf14")));
-extern ftype Wf14b __attribute__((weakref ("wf14")));
+static ftype Wf14a __attribute__((weakref ("wf14")));
+static ftype Wf14b __attribute__((weakref ("wf14")));
extern ftype wf14 __attribute__((weak));
+#ifndef __APPLE__
#define chk(p) do { if (!p) abort (); } while (0)
+#else
+#define chk(p) /* */
+#endif
int main () {
chk (!pv1a);
- chk (!pv1b);
- chk (!pv1c);
chk (pv2a);
chk (pv3a);
chk (pv4a);
@@ -203,7 +200,6 @@ int main () {
chk (!&Wv14a);
chk (!pf1a);
- chk (!pf1b);
chk (!pf1c);
chk (pf2a);
chk (pf3a);