This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Testsuite fix for weak function overriding
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 7 Jan 2009 19:26:43 +0000 (UTC)
- Subject: Testsuite fix for weak function overriding
dg-require-weak tests for the availability of weak symbol support.
This in fact means different things in different tests.
* Weak functions may not need to be defined at link time.
* Weak functions can potentially be overridden at runtime.
On MinGW, the second does not hold; see i386_pe_binds_local_p. Thus,
two tests of how GCC does not optimize weak function references fail
on MinGW, because GCC knows the functions in question cannot be
overridden at runtime after all.
This patch adds a separate dg-require-weak-override to cover this case
and uses it in those tests. OK to commit?
2009-01-07 Joseph Myers <joseph@codesourcery.com>
* lib/target-supports.exp (check_weak_override_available): New.
* lib/target-supports-dg.exp (dg-require-weak-override): New.
* gcc.dg/tree-ssa/pr27781.c, g++.dg/eh/weak1.C: Use
dg-require-weak-override.
Index: gcc.dg/tree-ssa/pr27781.c
===================================================================
--- gcc.dg/tree-ssa/pr27781.c (revision 143161)
+++ gcc.dg/tree-ssa/pr27781.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-require-weak "" } */
+/* { dg-require-weak-override "" } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
void __attribute__((weak)) func(void)
Index: g++.dg/eh/weak1.C
===================================================================
--- g++.dg/eh/weak1.C (revision 143161)
+++ g++.dg/eh/weak1.C (working copy)
@@ -1,6 +1,6 @@
// PR target/29487
// { dg-do run { xfail { hppa*-*-hpux* && { ! hppa*64*-*-* } } } }
-// { dg-require-weak "" }
+// { dg-require-weak-override "" }
// { dg-additional-sources "weak1-a.cc" }
// { dg-options "-O2" }
Index: lib/target-supports-dg.exp
===================================================================
--- lib/target-supports-dg.exp (revision 143161)
+++ lib/target-supports-dg.exp (working copy)
@@ -29,6 +29,21 @@
}
}
+# If this target does not support overriding weak symbols, skip this
+# test.
+
+proc dg-require-weak-override { args } {
+ set weak_override_available [ check_weak_override_available ]
+ if { $weak_override_available == -1 } {
+ upvar name name
+ unresolved "$name"
+ }
+ if { $weak_override_available != 1 } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ }
+}
+
# If this target does not support the "visibility" attribute, skip this
# test.
Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp (revision 143161)
+++ lib/target-supports.exp (working copy)
@@ -251,6 +251,20 @@
}
###############################
+# proc check_weak_override_available { }
+###############################
+
+# Like check_weak_available, but return 0 if weak symbol definitions
+# cannot be overridden.
+
+proc check_weak_override_available { } {
+ if { [istarget "*-*-mingw*"] } {
+ return 0
+ }
+ return [check_weak_available]
+}
+
+###############################
# proc check_visibility_available { what_kind }
###############################
--
Joseph S. Myers
joseph@codesourcery.com