From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 131253858D33 for ; Sun, 19 Nov 2023 11:27:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 131253858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 131253858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700393227; cv=none; b=IGSTHcRs3ElVk2NOYUSiRXNPpbVYQiJYZ7RgSholqKfenkjtJw8SW5OKSuc+CWOEcp58Tj71auqX4HmN9mX0tIwTCf34b0d/9upG8w8HO2p3+epJECL31c8n8cg2TSUrNT7A2Dk4tFkqFmbRz02KvEGEgpTzisS1r+fepcF57pM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700393227; c=relaxed/simple; bh=VORI34Buz1eTIbASme1pzfkoj0SaOcRiEBsHSDVA6KE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=La2nUWF2Wgotp3Iov+/YlqTpkklFSYbzCMz/Ry2TfGitLeA03rMzX+XNgkLw3ZDceAg9eM26+nwnLnMQeOTIqsEyNFFVbmvKO4XvxU2wL2v4/lEpGFS67NDCunIce04u6PNH4UkHxYv1+YmzCm0D3bZI1PaIliYUVHqCD3vFQto= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5437269a661so8798333a12.0 for ; Sun, 19 Nov 2023 03:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1700393224; x=1700998024; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=6HmWuGMrP/139AU/FA3DuCEnnKXrQ4e0PD4NTEhmb1U=; b=ASW8TZVDdvq8Ta1U18UIcjqXEyF+Cfmv+DNF+2SNTk6KdriuFtp/rMsgFbzZnJnYaP PIQNmudaQhx3p4UCgkiWB7/c2Yd7/H6dvn2DVGihwnhI7cWgc/ed+uLxzSnMea/xAk89 hypEPWP8w87+GQSQ9hstyrYz7Qah+sz3WS1XRYDNR8czdHDLd4Gpqef/tzauJuLZYJfg B4IAKedLZG+bYj5CsEg+9VUipXEhkx/rZwoynRJgWB5ZE3rYJHGOztxhtrfHCimFKgiw 8H4rn+XV917ZzKpgdfFZna8MZYp/aqmX3Nw1OdmwcSLbE1aZHoFNREtytVIHFUrCTNMJ +nLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700393224; x=1700998024; h=mime-version:user-agent:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6HmWuGMrP/139AU/FA3DuCEnnKXrQ4e0PD4NTEhmb1U=; b=sVBgU+9jiju6KmWYOe/VBYYDR1E+1Cip9vZYjuLxIzpuoeKy56rvfJFpDHJCExtWLj JSseZWBGq2jktOZnMDIFbc+jKOwwofzfiqMLoj2hMCfgC55P9lDExF6vd6YzHcwfKJ04 33pq0uFrPzKJDVWdH7crICbd0ZV2HhetVkMddWGmXKoFwOFtNO3ZcS7jBejju2z1f1K4 By+Q9LNCssF5n/psouLiAviOzLW2TJyn8RpmqWH604n2PyIQrW1cdNYB2xHbHgrAxj+/ GHbBWAT/8p456BwJQoaFI6+hC8BCxTHKGXXUuYni9qRln1B5ZNrq0Zadlj+/tNUAntUV so9g== X-Gm-Message-State: AOJu0YyE7Bmedvh7IMh5bxLdbxm12wYPrXVTNv/jR6woNxiMDh1HAWaP XFqT/tphepQPnfmjK5bIIByZukEMRtG14bsh54OozA== X-Google-Smtp-Source: AGHT+IECcsm2Uf+iGhFtjeKdJ/so73ZRgOJIsr2zeefdl+PRsEetExxlZ/eNosJsH4F8+W0z98hXLQ== X-Received: by 2002:a17:906:112:b0:9fd:79b3:e2b3 with SMTP id 18-20020a170906011200b009fd79b3e2b3mr763853eje.9.1700393224221; Sun, 19 Nov 2023 03:27:04 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id a21-20020a50ff15000000b0053de19620b9sm2463693edu.2.2023.11.19.03.27.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Nov 2023 03:27:03 -0800 (PST) Date: Sun, 19 Nov 2023 11:27:02 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Rainer Orth , Mike Stump Subject: [PATCH] testsuite: Fix subexpressions with `scan-assembler-times' Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,KAM_TK,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- Hi, Verified with the `riscv64-linux-gnu' target and the C language testsuite. OK to apply? Maciej --- gcc/testsuite/lib/scanasm.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) gcc-test-scan-assembler-times-count.diff Index: gcc/gcc/testsuite/lib/scanasm.exp =================================================================== --- gcc.orig/gcc/testsuite/lib/scanasm.exp +++ gcc/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 {