From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1256) id 690E3385828F; Thu, 23 Nov 2023 16:16:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 690E3385828F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700756211; bh=zmR0rJyo+7utNPE03V6YWO6tO9h9fDCiwW8n8oTHF7Y=; h=From:To:Subject:Date:From; b=sEMCXNLsfaRvt5m8BjZCURM6gcsai+BVGbInlzav8RUzOFHphkIK81cWZqIOMqNVe T1943l/nxzOCOmOPD2Hwx9EJhOrGgF63RCE3pEIELVSgbbjOweJJ4lD1+1gP5UkEmY 13qAaT5bKpF40HujbK/Vj5QexbIRY0akjOdYpgBI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Maciej W. Rozycki To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-5789] testsuite: Fix subexpressions with `scan-assembler-times' X-Act-Checkin: gcc X-Git-Author: Maciej W. Rozycki X-Git-Refname: refs/heads/master X-Git-Oldrev: 6ab2ae97fcf10590f23c6f631ed9afe7698cd243 X-Git-Newrev: ba0869323e1d45b1328b4cb723cb139a2e2146c3 Message-Id: <20231123161651.690E3385828F@sourceware.org> Date: Thu, 23 Nov 2023 16:16:51 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ba0869323e1d45b1328b4cb723cb139a2e2146c3 commit r14-5789-gba0869323e1d45b1328b4cb723cb139a2e2146c3 Author: Maciej W. Rozycki Date: Thu Nov 23 16:13:59 2023 +0000 testsuite: Fix subexpressions with `scan-assembler-times' We have an issue with `scan-assembler-times' handling expressions using subexpressions as produced by capturing parentheses `()' in an odd way, and one that is inconsistent with `scan-assembler', `scan-assembler-not', etc. The problem comes from calling `regexp' with `-inline -all', which causes a list to be returned that would otherwise be placed in match variables. Consequently if we have say: /* { dg-final { scan-assembler-times "\\s(foo|bar)\\s" 1 } } */ in a test case and there is a lone `foo' present in output being matched, then our invocation of `regexp -inline -all' in `scan-assembler-times' will return: { foo } foo and that in turn will confuse our match count calculation as `llength' will return 2 rather than 1, making the test fail even though `foo' was only actually matched once. It seems unclear why we chose to call `regexp' in such an odd way in the first place just to figure out the number of matches. The first version of TCL that supports the `-all' option to `regexp' is 8.3, and according to its documentation[1][2] `regexp' already returns the number of matches found whenever `-all' has been used *unless* `-inline' has also been used. Remove the `-inline' option then along with the `llength' invocation. References: [1] "Tcl Built-In Commands - regexp manual page", [2] "Tcl Built-In Commands - regexp manual page", gcc/testsuite/ * lib/scanasm.exp (scan-assembler-times): Remove the `-inline' option to `regexp' and the wrapping `llength' call. Diff: --- gcc/testsuite/lib/scanasm.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index 85ee54ff9a8..4fbf65744e9 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -505,7 +505,7 @@ proc scan-assembler-times { args } { close $fd regsub -all {(^|\n)[[:space:]]*\.section[[:space:]]*\.gnu\.lto_(?:[^\n]*\n(?![[:space:]]*\.(section|text|data|bss)))*[^\n]*\n} $text {\1} text - set result_count [llength [regexp -inline -all -- $pattern $text]] + set result_count [regexp -all -- $pattern $text] if {$result_count == $times} { pass "$testcase scan-assembler-times $pp_pattern $times" } else {