This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, testsuite, 2/2] Add scan-ltrans-tree-dump
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>, Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>, Mike Stump <mikestump at comcast dot net>
- Cc: <gcc-patches at gcc dot gnu dot org>, Richard Biener <rguenther at suse dot de>
- Date: Wed, 4 Apr 2018 10:59:23 +0200
- Subject: Re: [PATCH, testsuite, 2/2] Add scan-ltrans-tree-dump
- References: <577d48e8-0290-fb54-eca1-e9f845114e1e@mentor.com> <b0338e99-8cdc-b6ff-0d36-be1e6beccf65@mentor.com> <5ABE2E66-D1D3-421C-9EDF-453E085A5A56@gmail.com>
On 04/03/2018 07:49 PM, Bernhard Reutner-Fischer wrote:
This patch adds scan-ltrans-tree-dump.
Please check all error calls to talk about the correct function -- at least scan-ltrans-tree-dump-times is wrong.
Hi,
thanks for noticing that. I'll update the patches to fix that.
But I wonder if it's not a better idea to get the function name using
"info level", and to move the code that checks the number of arguments
into a utility function, as done in the demonstrator patch below.
Rainer, Mike, any comments? I can write a patch that uses check_num_args
in testsuite/lib/*.exp (though I'm not yet sure where to move it such
that it can be used everywhere).
Thanks,
- Tom
diff --git a/gcc/testsuite/lib/scanltranstree.exp b/gcc/testsuite/lib/scanltranstree.exp
index c122abb..e4c5c90 100644
--- a/gcc/testsuite/lib/scanltranstree.exp
+++ b/gcc/testsuite/lib/scanltranstree.exp
@@ -19,6 +19,25 @@
load_lib scandump.exp
+proc check_num_args { args } {
+ set caller_args [lindex $args 0]
+ set min_args [lindex $args 1]
+ if { [lindex $args] >= 2 } {
+ set max_args [lindex $args 2]
+ } else {
+ set max_args $min_args
+ }
+ set caller_fnname [lindex [info level -1] 0]
+ if { [llength $caller_args] < $min_args } {
+ error "$caller_fnname: too few arguments"
+ return
+ }
+ if { [llength $caller_args] > $max_args } {
+ error "$caller_fnname: too many arguments"
+ return
+ }
+}
+
# Utility for scanning compiler result, invoked via dg-final.
# Call pass if pattern is present, otherwise fail.
#
@@ -52,14 +71,7 @@ proc scan-ltrans-tree-dump { args } {
# Argument 3 handles expected failures and the like
proc scan-ltrans-tree-dump-times { args } {
- if { [llength $args] < 3 } {
- error "scan-ltrans-tree-dump: too few arguments"
- return
- }
- if { [llength $args] > 4 } {
- error "scan-ltrans-tree-dump: too many arguments"
- return
- }
+ check_num_args $args 3 4
if { [llength $args] >= 4 } {
scan-dump-times "ltrans-tree" [lindex $args 0] [lindex $args 1] \
"\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 2]" \