[COMMITTED] testsuite: Fix dg-do-if
Checks
Commit Message
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
Comments
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
> 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.
Thanks for fixing this.
> I cannot help thinking that dg-do-if is overkill: it's only used in 4
> test cases and never actually worked.
The original intention might have been to support older versions of
DejaGNU, which required all dg-do lines in a testcase to specify the
same action. Thus something like:
/* { dg-do compile { target { ! can-assembler-this } } } */
/* { dg-do assemble { target can-assemble-this } } */
would only work with newer DejaGNU.
Richard
On Apr 6, 2026, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
> I cannot help thinking that dg-do-if is overkill: it's only used in 4
> test cases and never actually worked.
There are other patches pending review that add more uses. One of them
even fixed this bug. Someone else submitted a patch to fix it as well.
Thanks for finally getting the fix in!
Hi Alex,
> On Apr 6, 2026, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>
>> I cannot help thinking that dg-do-if is overkill: it's only used in 4
>> test cases and never actually worked.
>
> There are other patches pending review that add more uses. One of them
> even fixed this bug. Someone else submitted a patch to fix it as well.
I obviously missed that. I did my patch out of pure self-preservation:
two of my test systems were affected and so I started looking into the
issue to reduce the noise.
Rainer
# HG changeset patch
# Parent eda78d3442ceaf2f46fa3d600b731501478cb561
testsuite: Fix dg-do-if
@@ -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 }
}