diff mbox series

[testsuite] Make lto.exp work with Tcl 8.4

Message ID 87r2pz1fw7.fsf@linaro.org
State New
Headers show
Series [testsuite] Make lto.exp work with Tcl 8.4 | expand

Commit Message

Richard Sandiford Feb. 5, 2018, 5:54 p.m. UTC
"dict" was added in Tcl 8.5, but until a couple of weeks ago the
testsuite has worked with 8.4.

This patch uses arrays instead, like we do for the caching in
target-supports.exp.  It is a bit uglier than using dicts was,
but hopefully not too bad...

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Richard


2018-02-05  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/testsuite/
	* lib/lto.exp (lto_handle_diagnostics): Remove messages_by_file
	argument and use dg-messages-by-file instead.  Expect it to be
	an array rather than a dict.
	(lto-link-and-maybe-run): Remove messages_by_file argument and
	use an upvar for dg-messages-by-file.  Update call to
	lto_handle_diagnostics.
	(lt-get-options): Treat dg-messages-by-file as an array
	rather than a dict.
	(lto-get-options-main): Likewise.  Set the entry rather than appending.
	(lto-execute): Treat dg-messages-by-file as an array rather than
	a dict.  Update call to lto-link-and-maybe-run.

Comments

Mike Stump Feb. 5, 2018, 9:12 p.m. UTC | #1
On Feb 5, 2018, at 9:54 AM, Richard Sandiford <richard.sandiford@linaro.org> wrote:
> 

> "dict" was added in Tcl 8.5, but until a couple of weeks ago the

> testsuite has worked with 8.4.

> 

> This patch uses arrays instead, like we do for the caching in

> target-supports.exp.  It is a bit uglier than using dicts was,

> but hopefully not too bad...

> 

> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?


Ok.
diff mbox series

Patch

Index: gcc/testsuite/lib/lto.exp
===================================================================
--- gcc/testsuite/lib/lto.exp	2018-01-19 11:57:10.397017291 +0000
+++ gcc/testsuite/lib/lto.exp	2018-02-05 17:51:17.386215067 +0000
@@ -111,18 +111,22 @@  proc lto_handle_diagnostics_for_file { n
 # the expected diagnostics within TEXT, issuing PASS/FAIL results.
 # Return TEXT, stripped of any diagnostics that were handled.
 #
-# MESSAGES_BY_FILE is a dict; the keys are source files (with paths)
-# the values are lists of expected messages, akin to DejaGnu's "dg-messages"
-# variable.
 # TEXT is the textual output from the LTO link.
 
-proc lto_handle_diagnostics { messages_by_file text } {
+proc lto_handle_diagnostics { text } {
     global testcase
 
+    upvar dg-messages-by-file messages_by_file
+
     verbose "lto_handle_diagnostics: entry: $text" 2
-    verbose "  messages_by_file $messages_by_file" 3
 
-    dict for {src dg-messages} $messages_by_file {
+    if { ![array exists messages_by_file] } {
+	error "lto_handle_diagnostics: messages_by_file not defined"
+    }
+
+    foreach src [lsort [array names messages_by_file]] {
+	set dg-messages $messages_by_file($src)
+	verbose "  messages for $src: ${dg-messages}" 3
 	set text [lto_handle_diagnostics_for_file $testcase $src \
 		      ${dg-messages} $text]
     }
@@ -294,16 +298,15 @@  proc lto-obj { source dest optall optfil
 # OPTALL is a list of compiler and linker options to use for all tests
 # OPTFILE is a list of compiler and linker options to use for this test
 # OPTSTR is the list of options to list in messages
-# MESSAGES_BY_FILE is a dict of (src, dg-messages)
-proc lto-link-and-maybe-run { testname objlist dest optall optfile optstr \
-			      messages_by_file } {
+proc lto-link-and-maybe-run { testname objlist dest optall optfile optstr } {
     global testcase
     global tool
     global compile_type
     global board_info
 
+    upvar dg-messages-by-file dg-messages-by-file
+
     verbose "lto-link-and-maybe-run" 2
-    verbose "  messages_by_file $messages_by_file" 3
 
     # Check that all of the objects were built successfully.
     foreach obj [split $objlist] {
@@ -342,7 +345,7 @@  proc lto-link-and-maybe-run { testname o
     }
 
     # Check for diagnostics specified by directives
-    set comp_output [lto_handle_diagnostics $messages_by_file $comp_output]
+    set comp_output [lto_handle_diagnostics $comp_output]
 
     # Prune unimportant visibility warnings before checking output.
     set comp_output [lto_prune_warns $comp_output]
@@ -527,7 +530,7 @@  proc lto-get-options-main { src } {
     }
 
     verbose "dg-messages: ${dg-messages}" 3
-    dict append dg-messages-by-file $src ${dg-messages}
+    set dg-messages-by-file($src) ${dg-messages}
 
     # Return flags to use for compiling the primary source file and for
     # linking.
@@ -578,7 +581,11 @@  proc lto-get-options { src } {
     }
 
     verbose "dg-messages: ${dg-messages}" 3
-    dict append dg-messages-by-file $src ${dg-messages}
+    if { [info exists dg-messages-by-file($src)] } {
+	append dg-messages-by-file($src) ${dg-messages}
+    } else {
+	set dg-messages-by-file($src) ${dg-messages}
+    }
 
     return ${dg-extra-tool-flags}
 }
@@ -609,7 +616,7 @@  proc lto-execute { src1 sid } {
     verbose "lto-execute: $src1" 1
     set compile_type "run"
     set dg-do-what [list ${dg-do-what-default} "" P]
-    set dg-messages-by-file [dict create]
+    array set dg-messages-by-file [list]
     set extra_flags(0) [lto-get-options-main $src1]
     set compile_xfail(0) "" 
 
@@ -733,7 +740,7 @@  proc lto-execute { src1 sid } {
 	    lto-link-and-maybe-run \
 		    "[lindex $obj_list 0]-[lindex $obj_list end]" \
 		    $obj_list $execname $filtered ${dg-extra-ld-options} \
-		    $filtered ${dg-messages-by-file}
+		    $filtered
 	}