Hi! On 2025-02-22T22:51:36+0100, I wrote: > On 2025-02-22T22:49:47+0100, I wrote: >> Pushed to trunk branch commit f553b1aaa2b1b925c918e5dcf966290b045321c2 >> "Refactor duplicated code into >> 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'", >> [...]
> --- a/gcc/testsuite/lib/gcc-dg.exp > +++ b/gcc/testsuite/lib/gcc-dg.exp > +# 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 > + } > +} Pushed to trunk branch commit e8e228acffe382f003a7f2ca37c068a5e0c74df4 "Gracefully handle the case that 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what' has not been called (indirectly) from 'dg-test'", see attached, to prepare for another use case. Grüße Thomas
>From e8e228acffe382f003a7f2ca37c068a5e0c74df4 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwi...@baylibre.com> Date: Fri, 21 Feb 2025 21:54:59 +0100 Subject: [PATCH] Gracefully handle the case that 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what' has not been called (indirectly) from 'dg-test' No change in behavior intended. gcc/testsuite/ * lib/gcc-dg.exp (find-dg-do-what): Gracefully handle the case that we've not be called (indirectly) from 'dg-test'. * lib/target-supports.exp (check_effective_target_stack_size) (check_effective_target_alloca): Catch this. --- gcc/testsuite/lib/gcc-dg.exp | 6 +++++- gcc/testsuite/lib/target-supports.exp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 6e9a7b207ab..c0adef6c450 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -1375,8 +1375,9 @@ set dg_runtest_extra_prunes "" # 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 level [info level] set lookup_level 2 - while true { + while { $lookup_level <= $level } { 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 @@ -1384,4 +1385,7 @@ proc find-dg-do-what { } { } incr lookup_level } + # We've not be called (indirectly) from 'dg-test'. + verbose "find-dg-do-what: have not found 'dg-do-what'" 2 + return [list] } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 7b3172d55b4..4970536bb59 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -653,6 +653,9 @@ proc check_effective_target_stack_size { } { # For nvptx target, stack size limits are relevant for execution only. if { [istarget nvptx-*-*] } { set dg-do-what [find-dg-do-what] + if { ![llength ${dg-do-what}] } { + error "unexpected call stack" + } if { ![string equal [lindex ${dg-do-what} 0] run] } { return 0 } @@ -1014,6 +1017,9 @@ proc check_effective_target_alloca {} { } set dg-do-what [find-dg-do-what] + if { ![llength ${dg-do-what}] } { + error "unexpected call stack" + } 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', -- 2.34.1