Refactor duplicated code into 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'

No change in behavior intended.

	gcc/testsuite/
	* lib/gcc-dg.exp (proc find-dg-do-what): New.
	* lib/target-supports.exp (check_effective_target_stack_size)
	(check_effective_target_alloca): Use it.
This commit is contained in:
Thomas Schwinge
2025-02-21 19:42:28 +01:00
parent 2abc942fd4
commit f553b1aaa2
2 changed files with 18 additions and 18 deletions

View File

@@ -1369,3 +1369,19 @@ proc gcc-transform-out-of-tree { args } {
set additional_prunes ""
set dg_runtest_extra_prunes ""
# Find the 'dg-do-what' variable living inside DejaGnu's 'dg-test' procedure,
# as a local variable. We start looking at the second-outer frame: this way,
# the caller of 'find-dg-do-what' may maintain a local 'dg-do-what' variable
# without interfering with this search.
proc find-dg-do-what { } {
set lookup_level 2
while true {
upvar $lookup_level dg-do-what dg-do-what
if { [info exists dg-do-what] } {
verbose "find-dg-do-what: found 'dg-do-what' at level $lookup_level: ${dg-do-what}" 2
return ${dg-do-what}
}
incr lookup_level
}
}

View File

@@ -652,15 +652,7 @@ proc check_effective_target_trampolines { } {
proc check_effective_target_stack_size { } {
# For nvptx target, stack size limits are relevant for execution only.
if { [istarget nvptx-*-*] } {
# Find 'dg-do-what' in an outer frame.
set level 1
while true {
upvar $level dg-do-what dg-do-what
if [info exists dg-do-what] then break
incr level
}
verbose "check_effective_target_stack_size: found dg-do-what at level $level" 2
set dg-do-what [find-dg-do-what]
if { ![string equal [lindex ${dg-do-what} 0] run] } {
return 0
}
@@ -1021,15 +1013,7 @@ proc check_effective_target_alloca {} {
return 0
}
# Find 'dg-do-what' in an outer frame.
set level 1
while true {
upvar $level dg-do-what dg-do-what
if [info exists dg-do-what] then break
incr level
}
verbose "check_effective_target_alloca: found dg-do-what at level $level" 2
set dg-do-what [find-dg-do-what]
if { [string equal [lindex ${dg-do-what} 0] run] } {
# For 'dg-do run', it additionally depends on runtime support.
# (If not supported, we don't try to demote 'run' to 'link',