[COMMITTED] testsuite: Fix dg-do-if

Message ID yddecksqnpp.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers
Series [COMMITTED] testsuite: Fix dg-do-if |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply

Commit Message

Rainer Orth April 6, 2026, 12:26 p.m. UTC
  Tests that use dg-do-if ERROR when the target selector matches, e.g.

ERROR: gcc.dg/vect/vect-simd-clone-16f.c -flto -ffat-lto-objects: compile: syntax error for " dg-do-if 1 compile { target { sse2_runtime && { ! sse4_runtime } } } "

While the error message isn't particularly helpful, it's from dg.exp
(dg-do): like the other dg-* procs it expects the line number to be the
first argument.  However, dg-do-if strips that, so dg-do gets the target
selector instead of the expected action keyword.

Fixed by no longer stripping the line number.

Tested on amd64-pc-freebsd15.0 (sse2_runtime && !sse4_runtime),
i386-pc-solaris2.11 and x86_64-pc-linux-gnu (sse2_runtime &&
sse4_runtime).

Committed to trunk.


I cannot help thinking that dg-do-if is overkill: it's only used in 4
test cases and never actually worked.

	Rainer
  

Patch

# HG changeset patch
# Parent  eda78d3442ceaf2f46fa3d600b731501478cb561
testsuite: Fix dg-do-if

diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -422,9 +422,8 @@  proc check-flags { args } {
 # (possibly the default) prevails.
 
 proc dg-do-if { args } {
-    set args [lreplace $args 0 0]
     # Verify the number of arguments.
-    if { [llength $args] != 2 } {
+    if { [llength $args] != 3 } {
 	error "syntax error, need a single action and target selector"
     }
 
@@ -435,7 +434,7 @@  proc dg-do-if { args } {
     }
     
     # Evaluate selector, return if it does not match.
-    switch [dg-process-target-1 [lindex $args 1]] {
+    switch [dg-process-target-1 [lindex $args 2]] {
 	"N" { return }
 	"P" { return }
     }