[ was: [PATCH, testsuite/guality] Use line number vars in gdb-test ] On Wed, Jul 04, 2018 at 08:32:49PM +0100, Richard Sandiford wrote: > Tom de Vries <tdevr...@suse.de> writes: > > +proc dg-final { args } { > > + upvar dg-final-code final-code > > + > > + if { [llength $args] > 2 } { > > + error "[lindex $args 0]: too many arguments" > > + } > > + set line [lindex $args 0] > > + set code [lindex $args 1] > > + set directive [lindex $code 0] > > + set withline \ > > + [switch $directive { > > + gdb-test {expr {1}} > > + default {expr {0}} > > + }] > > + if { $withline == 1 } { > > + set code [linsert $code 1 $line] > > + } > > + append final-code "$code\n" > > +} > > Like the idea, but I think: > > set withline \ > [switch $directive { > gdb-test {expr {1}} > default {expr {0}} > }] > if { $withline == 1 } { > set code [linsert $code 1 $line] > } > > would be clearer as: > > switch $directive { > gdb-test { > set code [linsert $code 1 $line] > } > }
Agreed, thanks for the comment. Committed as below. Thanks, - Tom [testsuite] Simplify dg-final 2018-07-05 Tom de Vries <tdevr...@suse.de> * lib/gcc-dg.exp (dg-final): Simplify tcl code. --- gcc/testsuite/lib/gcc-dg.exp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 9e0b3f4ef95..f5e6bef5dd9 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -123,13 +123,10 @@ proc dg-final { args } { set line [lindex $args 0] set code [lindex $args 1] set directive [lindex $code 0] - set withline \ - [switch $directive { - gdb-test {expr {1}} - default {expr {0}} - }] - if { $withline == 1 } { - set code [linsert $code 1 $line] + switch $directive { + gdb-test { + set code [linsert $code 1 $line] + } } append final-code "$code\n" }