Skip to content

Commit d4c4542

Browse files
committed
gdb/testsuite: remove use of then keyword from library files
The canonical form of 'if' in modern TCL is 'if {} {}'. But there's still a bunch of places in the testsuite where we make use of the 'then' keyword, and sometimes these get copies into new tests, which just spreads poor practice. This commit removes all use of the 'then' keyword from the testsuite library files (in boards/, config/, and lib/). Previous commits have removed all uses of the 'then' keyword from the test script files, this commit just cleans up the library files. There should be no changes in what is tested after this commit.
1 parent f50c72d commit d4c4542

File tree

11 files changed

+109
-109
lines changed

11 files changed

+109
-109
lines changed

gdb/testsuite/boards/native-extended-gdbserver.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ proc gdb_reload { {inferior_args {}} } {
113113
# to a separate non-dbx testcase, we should be able to remove this.
114114
proc gdb_load { arg } {
115115
if { $arg != "" } {
116-
if [gdb_file_cmd $arg] then { return -1 }
116+
if {[gdb_file_cmd $arg]} { return -1 }
117117
}
118118

119119
return [extended_gdbserver_load_last_file]
@@ -129,7 +129,7 @@ proc mi_gdb_load { arg } {
129129
global mi_gdb_prompt
130130

131131
set res [extended_gdbserver_mi_gdb_load $arg]
132-
if { $res } then { return -1 }
132+
if {$res} { return -1 }
133133

134134
send_gdb "100-gdb-set remote exec-file $arg\n"
135135
gdb_expect 10 {

gdb/testsuite/config/sid.exp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ proc sid_start {} {
2222
{ *big-endian* *-EB* *-meb* } { set sidendian "-EB" }
2323
{ *little-endian* *-EL* *-mel* } { set sidendian "-EL" }
2424
default {
25-
if {[target_info exists sim,defaultendian]} then {
25+
if {[target_info exists sim,defaultendian]} {
2626
set sidendian [target_info sim,defaultendian]
2727
} else {
2828
# rely on endianness settings in sid configuration defaults
@@ -39,12 +39,12 @@ proc sid_start {} {
3939
# test to see whether to use use sid in build or install tree
4040
set use_build_tree [file exists ../../sid]
4141

42-
if {$use_build_tree} then {
42+
if {$use_build_tree} {
4343
set pre_spawn {
4444
global env
4545
set env(SID_LIBRARY_PATH) [join [glob "../../sid/component/*"] ":"]
4646
set env(SID) "../../sid/main/dynamic/sid"
47-
if {! [file exists $env(SID)]} then { error "Cannot find sid in build tree" }
47+
if {![file exists $env(SID)]} { error "Cannot find sid in build tree" }
4848
}
4949
if { [board_info target sim,protocol] == "sid" } {
5050
set spawncmd "[target_info sim] [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
@@ -169,7 +169,7 @@ proc gdb_load { arg } {
169169
global retval
170170

171171
if { $arg != "" } {
172-
if [gdb_file_cmd $arg] then { return -1 }
172+
if {[gdb_file_cmd $arg]} { return -1 }
173173
}
174174

175175
gdb_target_sid
@@ -181,25 +181,25 @@ proc gdb_load { arg } {
181181
verbose "Timeout is now $timeout seconds" 2
182182
gdb_expect {
183183
-re ".*\[Ee\]rror.*$gdb_prompt $" {
184-
if $verbose>1 then {
184+
if {$verbose > 1} {
185185
perror "Error during download."
186186
}
187187
set retval -1
188188
}
189189
-re ".*$gdb_prompt $" {
190-
if $verbose>1 then {
190+
if {$verbose > 1} {
191191
send_user "Loaded $arg into $GDB\n"
192192
}
193193
set retval 0
194194
}
195195
-re "$gdb_prompt $" {
196-
if $verbose>1 then {
196+
if {$verbose > 1} {
197197
perror "GDB couldn't load."
198198
}
199199
set retval -1
200200
}
201201
timeout {
202-
if $verbose>1 then {
202+
if {$verbose > 1} {
203203
perror "Timed out trying to load $arg."
204204
}
205205
set retval -1

gdb/testsuite/config/sim.exp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,26 @@ proc gdb_load { arg } {
4848
global gdb_prompt
4949

5050
if { $arg != "" } {
51-
if [gdb_file_cmd $arg] then { return -1 }
51+
if {[gdb_file_cmd $arg]} { return -1 }
5252
}
5353

54-
if [gdb_target_sim] then { return -1 }
54+
if {[gdb_target_sim]} { return -1 }
5555

5656
send_gdb "load\n"
5757
gdb_expect 2400 {
5858
-re ".*$gdb_prompt $" {
59-
if $verbose>1 then {
59+
if {$verbose > 1} {
6060
send_user "Loaded $arg into $GDB\n"
6161
}
6262
return 0
6363
}
6464
-re "$gdb_prompt $" {
65-
if $verbose>1 then {
65+
if {$verbose > 1} {
6666
perror "GDB couldn't load."
6767
}
6868
}
6969
timeout {
70-
if $verbose>1 then {
70+
if {$verbose > 1} {
7171
perror "Timed out trying to load $arg."
7272
}
7373
}

gdb/testsuite/config/slite.exp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ proc gdb_load { arg } {
8383
}
8484
-re "Remote target.*$gdb_prompt $" { }
8585
-re ".*SPARClite appears to be alive.*$gdb_prompt $" {
86-
if $verbose>1 then {
86+
if {$verbose > 1} {
8787
send_user "Set target to $targetname\n"
8888
}
8989
}
@@ -119,12 +119,12 @@ proc gdb_load { arg } {
119119
verbose "Timeout is now $timeout seconds" 2
120120
}
121121
-re "$gdb_prompt $" {
122-
if $verbose>1 then {
122+
if {$verbose > 1} {
123123
perror "GDB couldn't load."
124124
}
125125
}
126126
timeout {
127-
if $verbose>1 then {
127+
if {$verbose > 1} {
128128
perror "Timed out trying to load $arg."
129129
}
130130
}
@@ -172,7 +172,7 @@ proc gdb_load { arg } {
172172
}
173173
}
174174

175-
if [info exists expect_out(buffer)] then {
175+
if {[info exists expect_out(buffer)]} {
176176
send_log $expect_out(buffer)
177177
}
178178
return 0

gdb/testsuite/lib/cp-support.exp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,16 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
251251
# The test name defaults to the command, but without the
252252
# arguments, for historical reasons.
253253

254-
if { "$in_testname" == "" } then { set in_testname "ptype $in_exp" }
254+
if {"$in_testname" == ""} { set in_testname "ptype $in_exp" }
255255

256256
set in_command "ptype${in_ptype_arg} $in_exp"
257257
}
258258

259259
# Save class tables in a history array for reuse.
260260

261261
global cp_class_table_history
262-
if { $in_class_table == "ibid" } then {
263-
if { ! [info exists cp_class_table_history("$in_key,$in_tag") ] } then {
262+
if {$in_class_table == "ibid"} {
263+
if {![info exists cp_class_table_history("$in_key,$in_tag")]} {
264264
fail "$in_testname // bad ibid"
265265
return false
266266
}
@@ -385,7 +385,7 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
385385

386386
# Check the actual tag.
387387

388-
if { "$actual_tag" != "$in_tag" } then {
388+
if {"$actual_tag" != "$in_tag"} {
389389
cp_check_errata "$in_tag" "$actual_tag" $in_errata_table
390390
fail "$in_testname // wrong tag: $actual_tag"
391391
return false
@@ -395,18 +395,18 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
395395
# First parse them into a list.
396396

397397
set list_actual_bases { }
398-
if { "$actual_base_string" != "" } then {
398+
if {"$actual_base_string" != ""} {
399399
regsub "^:${wsopt}" $actual_base_string "" actual_base_string
400400
set list_actual_bases [split $actual_base_string ","]
401401
}
402402

403403
# Check the base count.
404404

405-
if { [llength $list_actual_bases] < [llength $list_bases] } then {
405+
if {[llength $list_actual_bases] < [llength $list_bases]} {
406406
fail "$in_testname // too few bases"
407407
return false
408408
}
409-
if { [llength $list_actual_bases] > [llength $list_bases] } then {
409+
if {[llength $list_actual_bases] > [llength $list_bases]} {
410410
fail "$in_testname // too many bases"
411411
return false
412412
}
@@ -416,7 +416,7 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
416416
foreach actual_base $list_actual_bases {
417417
set actual_base [string trim $actual_base]
418418
set base [lindex $list_bases 0]
419-
if { "$actual_base" != "$base" } then {
419+
if {"$actual_base" != "$base"} {
420420
cp_check_errata "$base" "$actual_base" $in_errata_table
421421
fail "$in_testname // wrong base: $actual_base"
422422
return false
@@ -449,13 +449,13 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
449449
# Get the next line.
450450

451451
set actual_line [cp_support_internal::next_line $line_queue]
452-
if { "$actual_line" == "" } then { continue }
452+
if {"$actual_line" == ""} { continue }
453453

454454
# Access specifiers.
455455

456-
if { [regexp "^(public|protected|private)${wsopt}:\$" "$actual_line" s0 s1] } then {
456+
if {[regexp "^(public|protected|private)${wsopt}:\$" "$actual_line" s0 s1]} {
457457
set access "$s1"
458-
if { $last_was_access } then {
458+
if {$last_was_access} {
459459
fail "$in_testname // redundant access specifier"
460460
queue delete $line_queue
461461
return false
@@ -468,10 +468,10 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
468468

469469
# Optional virtual base pointer.
470470

471-
if { [ llength $list_vbases ] > 0 } then {
471+
if {[llength $list_vbases] > 0} {
472472
set vbase [lindex $list_vbases 0]
473-
if { [ regexp "$vbase \\*(_vb.|_vb\\\$|__vb_)\[0-9\]*$vbase;" $actual_line ] } then {
474-
if { "$access" != "private" } then {
473+
if {[regexp "$vbase \\*(_vb.|_vb\\\$|__vb_)\[0-9\]*$vbase;" $actual_line]} {
474+
if {"$access" != "private"} {
475475
cp_check_errata "private" "$access" $in_errata_table
476476
fail "$in_testname // wrong access specifier for virtual base: $access"
477477
queue delete $line_queue
@@ -485,7 +485,7 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
485485

486486
# Data field.
487487

488-
if { [llength $list_fields] > 0 } then {
488+
if {[llength $list_fields] > 0} {
489489
set field_access [lindex [lindex $list_fields 0] 0]
490490
set field_decl [lindex [lindex $list_fields 0] 1]
491491
if {$recursive_qid > 0} {
@@ -494,8 +494,8 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
494494
cp_ptype_class_verbose "\tfield_decl=$field_decl"
495495
cp_ptype_class_verbose "\taccess=$access"
496496
}
497-
if { "$actual_line" == "$field_decl" } then {
498-
if { "$access" != "$field_access" } then {
497+
if {"$actual_line" == "$field_decl"} {
498+
if {"$access" != "$field_access"} {
499499
cp_check_errata "$field_access" "$access" $in_errata_table
500500
fail "$in_testname // wrong access specifier for field: $access"
501501
queue delete $line_queue
@@ -514,11 +514,11 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
514514

515515
# Method function.
516516

517-
if { [llength $list_methods] > 0 } then {
517+
if {[llength $list_methods] > 0} {
518518
set method_access [lindex [lindex $list_methods 0] 0]
519519
set method_decl [lindex [lindex $list_methods 0] 1]
520-
if { "$actual_line" == "$method_decl" } then {
521-
if { "$access" != "$method_access" } then {
520+
if {"$actual_line" == "$method_decl"} {
521+
if {"$access" != "$method_access"} {
522522
cp_check_errata "$method_access" "$access" $in_errata_table
523523
fail "$in_testname // wrong access specifier for method: $access"
524524
queue delete $line_queue
@@ -530,8 +530,8 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
530530

531531
# gcc 2.95.3 shows "foo()" as "foo(void)".
532532
regsub -all "\\(\\)" $method_decl "(void)" method_decl
533-
if { "$actual_line" == "$method_decl" } then {
534-
if { "$access" != "$method_access" } then {
533+
if {"$actual_line" == "$method_decl"} {
534+
if {"$access" != "$method_access"} {
535535
cp_check_errata "$method_access" "$access" $in_errata_table
536536
fail "$in_testname // wrong access specifier for method: $access"
537537
queue delete $line_queue
@@ -689,16 +689,16 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
689689
set synth_access [lindex $synth 1]
690690
set synth_re [lindex $synth 2]
691691

692-
if { [ regexp "$synth_re" "$actual_line" ] } then {
692+
if {[regexp "$synth_re" "$actual_line"]} {
693693

694-
if { "$access" != "$synth_access" } then {
694+
if {"$access" != "$synth_access"} {
695695
cp_check_errata "$synth_access" "$access" $in_errata_table
696696
fail "$in_testname // wrong access specifier for synthetic operator: $access"
697697
queue delete $line_queue
698698
return false
699699
}
700700

701-
if { $synth_count > 0 } then {
701+
if {$synth_count > 0} {
702702
cp_check_errata "$actual_line" "$actual_line" $in_errata_table
703703
fail "$in_testname // duplicate synthetic operator: $actual_line"
704704
}
@@ -715,7 +715,7 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
715715
break
716716
}
717717
}
718-
if { $synth_match } then { continue }
718+
if {$synth_match} { continue }
719719

720720
# If checking a nested type/recursively and we see a closing curly
721721
# brace, we're done.
@@ -725,7 +725,7 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
725725

726726
# Unrecognized line.
727727

728-
if { [llength $list_methods] > 0 } then {
728+
if {[llength $list_methods] > 0} {
729729
set method_decl [lindex [lindex $list_methods 0] 1]
730730
cp_check_errata "$method_decl" "$actual_line" $in_errata_table
731731
}
@@ -742,19 +742,19 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
742742

743743
# Check for missing elements.
744744

745-
if { $vbase_match } then {
746-
if { [llength $list_vbases] > 0 } then {
745+
if {$vbase_match} {
746+
if {[llength $list_vbases] > 0} {
747747
fail "$in_testname // missing virtual base pointers"
748748
return false
749749
}
750750
}
751751

752-
if { [llength $list_fields] > 0 } then {
752+
if {[llength $list_fields] > 0} {
753753
fail "$in_testname // missing fields"
754754
return false
755755
}
756756

757-
if { [llength $list_methods] > 0 } then {
757+
if {[llength $list_methods] > 0} {
758758
fail "$in_testname // missing methods"
759759
return false
760760
}
@@ -767,7 +767,7 @@ proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
767767
# Check the tail.
768768

769769
set actual_tail [string trim $actual_tail]
770-
if { "$actual_tail" != "$in_tail" } then {
770+
if {"$actual_tail" != "$in_tail"} {
771771
cp_check_errata "$in_tail" "$actual_tail" $in_errata_table
772772
fail "$in_testname // wrong tail: $actual_tail"
773773
return false

gdb/testsuite/lib/dwarf.exp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ proc build_executable_and_dwo_files { testname executable options args } {
104104
global subdir
105105
global srcdir
106106

107-
if { ! [regexp "^/" "$executable"] } then {
107+
if {![regexp "^/" "$executable"]} {
108108
set binfile [standard_output_file $executable]
109109
} else {
110110
set binfile $executable
@@ -143,7 +143,7 @@ proc build_executable_and_dwo_files { testname executable options args } {
143143
set s [lindex $spec 0]
144144
set local_options [lindex $spec 1]
145145

146-
if { ! [regexp "^/" "$s"] } then {
146+
if {![regexp "^/" "$s"]} {
147147
set s "$srcdir/$subdir/$s"
148148
}
149149

@@ -1685,7 +1685,7 @@ namespace eval Dwarf {
16851685
proc base { addr } {
16861686
variable _debug_ranges_64_bit
16871687

1688-
if { $_debug_ranges_64_bit } then {
1688+
if {$_debug_ranges_64_bit} {
16891689
_op .8byte 0xffffffffffffffff "Base Marker"
16901690
_op .8byte $addr "Base Address"
16911691
} else {
@@ -1697,7 +1697,7 @@ namespace eval Dwarf {
16971697
proc range { start end } {
16981698
variable _debug_ranges_64_bit
16991699

1700-
if { $_debug_ranges_64_bit } then {
1700+
if {$_debug_ranges_64_bit} {
17011701
_op .8byte $start "Start Address"
17021702
_op .8byte $end "End Address"
17031703
} else {
@@ -1709,7 +1709,7 @@ namespace eval Dwarf {
17091709
uplevel $body
17101710

17111711
# End of the sequence.
1712-
if { $_debug_ranges_64_bit } then {
1712+
if {$_debug_ranges_64_bit} {
17131713
_op .8byte 0x0 "End of Sequence Marker (Part 1)"
17141714
_op .8byte 0x0 "End of Sequence Marker (Part 2)"
17151715
} else {

0 commit comments

Comments
 (0)