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]

[PATCH,PR43888] Weak symbols may bind non-locally on Windows.


    Hi!

  The attached patch fixes PR43888, "FAIL: gcc.dg/alias-7.c execution test".
In this testcase, GCC believes that two different function identifiers cannot
compare equal, despite the fact that one of them is a weak alias for the
other.  It turns out that fold_comparison falsely simplifies an inequality
test because it doesn't realise that a weak symbol may bind non-locally; the
TARGET_BINDS_LOCAL_P hook for PE/COFF, i386_pe_binds_local_p, hasn't been
updated since we got weak symbols working on Windows.

  This fixes the following extant C and C++ failures on i686-pc-cygwin:

-FAIL: g++.dg/eh/weak1.C execution test
-FAIL: gcc.dg/alias-7.c execution test
-FAIL: gcc.dg/tree-ssa/pr27781.c scan-tree-dump optimized "func \\(\\);"

gcc/ChangeLog:

	* config/i386/winnt.c (i386_pe_binds_local_p): Handle weak decls.

  Bootstrapped and tested(*) on i686-pc-cygwin; I'll apply this in 24 hours if
nobody objects.

    cheers,
      DaveK

--- origsrc/gcc-4.5.0/gcc/config/i386/winnt.c	2010-04-23 05:45:21.531250000 +0100
+++ src/gcc-4.5.0/gcc/config/i386/winnt.c	2010-04-25 16:05:19.296875000 +0100
@@ -321,6 +321,11 @@ i386_pe_binds_local_p (const_tree exp)
       && DECL_DLLIMPORT_P (exp))
     return false;
 
+  /* Or a weak one, now that they are supported.  */
+  if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
+      && DECL_WEAK (exp))
+    return false;
+
   return true;
 }
 


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