From d7001ae593744a2243c7674cae610f645ab18252 Mon Sep 17 00:00:00 2001 From: Geoffrey Keating Date: Mon, 3 Jan 2005 23:26:54 +0000 Subject: [PATCH] darwin.c (darwin_handle_weak_import_attribute): Permit VAR_DECLs to have weak_import attribute. 2005-01-03 Geoffrey Keating * config/darwin.c (darwin_handle_weak_import_attribute): Permit VAR_DECLs to have weak_import attribute. Index: testsuite/ChangeLog 2005-01-03 Geoffrey Keating * gcc.dg/darwin-weakimport-1.c: Remove check for variables producing warning. * gcc.dg/darwin-weakimport-2.c: New. From-SVN: r92871 --- gcc/ChangeLog | 3 +++ gcc/config/darwin.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/darwin-weakimport-1.c | 2 -- gcc/testsuite/gcc.dg/darwin-weakimport-2.c | 14 ++++++++++++++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/darwin-weakimport-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a1369db17b3..f94c25f202f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2005-01-03 Geoffrey Keating + * config/darwin.c (darwin_handle_weak_import_attribute): Permit + VAR_DECLs to have weak_import attribute. + * config/rs6000/darwin-fallback.c: Use 'ucontext_t' rather than 'struct ucontext'. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 4738fee911c..b95c438988e 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1228,7 +1228,7 @@ darwin_handle_weak_import_attribute (tree *node, tree name, int ARG_UNUSED (flags), bool * no_add_attrs) { - if (TREE_CODE (*node) != FUNCTION_DECL) + if (TREE_CODE (*node) != FUNCTION_DECL && TREE_CODE (*node) != VAR_DECL) { warning ("%qs attribute ignored", IDENTIFIER_POINTER (name)); *no_add_attrs = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 058df899faf..f74a542b2b4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-01-03 Geoffrey Keating + + * gcc.dg/darwin-weakimport-1.c: Remove check for variables + producing warning. + * gcc.dg/darwin-weakimport-2.c: New. + 2005-01-03 Richard Henderson * g++.old-deja/g++.ext/attrib5.C: Move the alias after the referent. diff --git a/gcc/testsuite/gcc.dg/darwin-weakimport-1.c b/gcc/testsuite/gcc.dg/darwin-weakimport-1.c index c797720e4e2..e74ccc98ae6 100644 --- a/gcc/testsuite/gcc.dg/darwin-weakimport-1.c +++ b/gcc/testsuite/gcc.dg/darwin-weakimport-1.c @@ -12,5 +12,3 @@ void b(void) { a(); } - -extern int c __attribute__((weak_import)); /* { dg-warning "ignored" } */ diff --git a/gcc/testsuite/gcc.dg/darwin-weakimport-2.c b/gcc/testsuite/gcc.dg/darwin-weakimport-2.c new file mode 100644 index 00000000000..1c802337ce2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/darwin-weakimport-2.c @@ -0,0 +1,14 @@ +/* APPLE LOCAL file put in 4.1 */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-require-weak "" } */ + +/* { dg-final { scan-assembler "weak_reference _foo" } } */ + +extern int foo __attribute__((weak_import)); + +int main(void) +{ + if (&foo) + return foo; + return 0; +} -- 2.30.2