Commit d66f0329 by Richard Sandiford Committed by Richard Sandiford

Make lto.exp work with Tcl 8.4

"dict" was added in Tcl 8.5, but until a couple of weeks ago the
testsuite had 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...

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.

From-SVN: r257397
parent 60d25b80
2018-02-05 Richard Sandiford <richard.sandiford@linaro.org>
* 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.
2018-02-05 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/82782
......
......@@ -111,18 +111,22 @@ proc lto_handle_diagnostics_for_file { name filename messages_for_file text } {
# 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 optfile optstr xfaildata } {
# 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 objlist dest optall optfile optstr \
}
# 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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment