aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Ellcey <sje@cup.hp.com>2006-05-10 21:55:34 +0000
committerSteve Ellcey <sje@gcc.gnu.org>2006-05-10 21:55:34 +0000
commit21f638b9b04b977159ff29ac9de97ffec40c607f (patch)
treedb63e8a13f99e4b2c59caa9d4a92533a7ebfd147
parent29e339b95aa44fa710257c2c79a64d31eb4b31d1 (diff)
downloadgcc-21f638b9b04b977159ff29ac9de97ffec40c607f.zip
gcc-21f638b9b04b977159ff29ac9de97ffec40c607f.tar.gz
gcc-21f638b9b04b977159ff29ac9de97ffec40c607f.tar.bz2
target-supports-dg.exp (dg-require-cxa-atexit): New.
* lib/target-supports-dg.exp (dg-require-cxa-atexit): New. * lib/target-supports.dg (check_cxa_atexit_available): New. From-SVN: r113684
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/lib/target-supports-dg.exp9
-rw-r--r--gcc/testsuite/lib/target-supports.exp87
3 files changed, 101 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 872070d..e21851c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-09 Steve Ellcey <sje@cup.hp.com>
+
+ * lib/target-supports-dg.exp (dg-require-cxa-atexit): New.
+ * lib/target-supports.dg (check_cxa_atexit_available): New.
+
2005-05-10 Thomas Koenig <Thomas.Koenig@online.de>
PR fortran/27470
diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp
index 4f77f85..b361b7f 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -140,6 +140,15 @@ proc dg-require-mkfifo { args } {
}
}
+# If this target does not use __cxa_atexit, skip this test.
+
+proc dg-require-cxa-atexit { args } {
+ if { ![ check_cxa_atexit_available ] } {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ }
+}
+
# Check the flags with which the test will be run against options in
# a test directive that will skip or xfail that test. The DejaGnu proc
# check_conditional_xfail will look at the options in compiler_flags, so
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index abe4fb9..d4242e6 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -916,6 +916,93 @@ proc check_mkfifo_available {} {
return [check_function_available "mkfifo"]
}
+# Returns true iff "__cxa_atexit" is used on the target system.
+
+proc check_cxa_atexit_available { } {
+ global et_cxa_atexit
+ global et_cxa_atexit_target_name
+ global tool
+
+ if { ![info exists et_cxa_atexit_target_name] } {
+ set et_cxa_atexit_target_name ""
+ }
+
+ # If the target has changed since we set the cached value, clear it.
+ set current_target [current_target_name]
+ if { $current_target != $et_cxa_atexit_target_name } {
+ verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
+ set et_cxa_atexit_target_name $current_target
+ if [info exists et_cxa_atexit] {
+ verbose "check_cxa_atexit_available: removing cached result" 2
+ unset et_cxa_atexit
+ }
+ }
+
+ if [info exists et_cxa_atexit] {
+ verbose "check_cxa_atexit_available: using cached result" 2
+ } else {
+ set et_cxa_atexit 0
+
+ # Set up, compile, and execute a C++ test program that depends
+ # on correct ordering of static object destructors. This is
+ # indicative of the presence and use of __cxa_atexit.
+ set src cxaatexit[pid].cc
+ set exe cxaatexit[pid].x
+
+ set f [open $src "w"]
+ puts $f "#include <stdlib.h>"
+ puts $f "static unsigned int count;"
+ puts $f "struct X"
+ puts $f "{"
+ puts $f " X() { count = 1; }"
+ puts $f " ~X()"
+ puts $f " {"
+ puts $f " if (count != 3)"
+ puts $f " exit(1);"
+ puts $f " count = 4;"
+ puts $f " }"
+ puts $f "};"
+ puts $f "void f()"
+ puts $f "{"
+ puts $f " static X x;"
+ puts $f "}"
+ puts $f "struct Y"
+ puts $f "{"
+ puts $f " Y() { f(); count = 2; }"
+ puts $f " ~Y()"
+ puts $f " {"
+ puts $f " if (count != 2)"
+ puts $f " exit(1);"
+ puts $f " count = 3;"
+ puts $f " }"
+ puts $f "};"
+ puts $f "Y y;"
+ puts $f "int main()"
+ puts $f "{ return 0; }"
+ close $f
+
+ set lines [v3_target_compile $src $exe executable ""]
+ file delete $src
+
+ if [string match "" $lines] {
+ # No error message, compilation succeeded.
+ set result [${tool}_load "./$exe" "" ""]
+ set status [lindex $result 0]
+ remote_file build delete $exe
+
+ verbose "check_cxa_atexit_available: status is <$status>" 2
+
+ if { $status == "pass" } {
+ set et_cxa_atexit 1
+ }
+ } else {
+ verbose "check_cxa_atexit_available: compilation failed" 2
+ }
+ }
+ return $et_cxa_atexit
+}
+
+
# Return 1 if we're generating 32-bit code using default options, 0
# otherwise.