This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

weak_import for VAR_DECLs


It turns out that variables were always supposed to be allowed to have
weak_import attached.

This is not a regression, but it was not present in earlier GCCs
either, so I'm committing it under my understanding of what Mark meant
by 'regression'.

Bootstrapped & tested on powerpc-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-3919904.patch=========================
2005-01-03  Geoffrey Keating  <geoffk@apple.com>

	* config/darwin.c (darwin_handle_weak_import_attribute): Permit
	VAR_DECLs to have weak_import attribute.

Index: testsuite/ChangeLog
2005-01-03  Geoffrey Keating  <geoffk@apple.com>

	* gcc.dg/darwin-weakimport-1.c: Remove check for variables
	producing warning.
	* gcc.dg/darwin-weakimport-2.c: New.

Index: config/darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.101
diff -u -p -u -p -r1.101 darwin.c
--- config/darwin.c	31 Dec 2004 22:07:47 -0000	1.101
+++ config/darwin.c	3 Jan 2005 23:22:16 -0000
@@ -1228,7 +1228,7 @@ darwin_handle_weak_import_attribute (tre
 				     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;
Index: testsuite/gcc.dg/darwin-weakimport-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/darwin-weakimport-1.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 darwin-weakimport-1.c
--- testsuite/gcc.dg/darwin-weakimport-1.c	27 Oct 2004 23:01:57 -0000	1.1
+++ testsuite/gcc.dg/darwin-weakimport-1.c	3 Jan 2005 23:22:17 -0000
@@ -12,5 +12,3 @@ void b(void)
 {
   a();
 }
-
-extern int c __attribute__((weak_import)); /* { dg-warning "ignored" } */
Index: testsuite/gcc.dg/darwin-weakimport-2.c
===================================================================
RCS file: testsuite/gcc.dg/darwin-weakimport-2.c
diff -N testsuite/gcc.dg/darwin-weakimport-2.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/darwin-weakimport-2.c	3 Jan 2005 23:22:17 -0000
@@ -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;
+}
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]