]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Gracefully handle the case that 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what' has...
authorThomas Schwinge <tschwinge@baylibre.com>
Fri, 21 Feb 2025 20:54:59 +0000 (21:54 +0100)
committerThomas Schwinge <tschwinge@baylibre.com>
Sat, 22 Feb 2025 21:37:50 +0000 (22:37 +0100)
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
gcc/testsuite/lib/target-supports.exp

index 6e9a7b207ab83316c4adb093a7833fdc1de35134..c0adef6c450eebfd62633e88120dadc93f1f5ab9 100644 (file)
@@ -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]
 }
index 7b3172d55b4501238de9cc97429422e6368908d6..4970536bb592b3b47801204d99ebd9c03e912cfb 100644 (file)
@@ -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',