From patchwork Sat Jul 27 20:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1965669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EzCwCgg+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WWbjx6DmTz1yYc for ; Sun, 28 Jul 2024 06:26:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 710B83857C4F for ; Sat, 27 Jul 2024 20:26:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id BFA493858D28 for ; Sat, 27 Jul 2024 20:25:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFA493858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BFA493858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722111948; cv=none; b=rML2bRrE1BlrHYyYOvFOuKXHbEJL4atcxd/WOpPxti7Ok62dtbx4HcA4TVFqAZOMXHTVKmUXR5VFBxt88/oQVN2jhQMAZKgWvrip5F/wJnCcxNrnmJuJq/poUDstQu9JnBmEv3T9+rXGenwMeHMnbsAOxQC4E9tdIj+GgLszMh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722111948; c=relaxed/simple; bh=upUaPUcocV0ItEErTYAm0Egz32wNiLqbrhvi9MSp59Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VO3gDvzp36XO5lk7SZz7ZNWO84wHf3qk7j5PnST2fwwXgfgAdvb6mE5Zcm1r15EDXeZuIyxGo7UulUuvY9Rsa1IL8BdmADV/WGun7aNm1wOgtgKmpk8MpLJV8XEaXnqNaOhzpg8wLp1rR9hOInzaQstMkVGd54dqV5nf1sDUM/0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722111946; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JSEIA5vJGcmNG47dRgeUTjefyDTAllzG94evQ6NLUTk=; b=EzCwCgg+KcjptRxduAdAX3UQuoWtMFrMlYl/S29+dgCUcNn78pNPRMWbHkJBAl+cEaHujI Icl56IWNs6+H00J6IEmA6f3wEPG6+QReucPF74daltI24Y1c74RhGqFWVN83hszrloaaAn LGbUlN38lbV2WcUjrCiIQuay8iBbnoQ= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-JFlVRlqNMdO8_Sl6Ee6iqw-1; Sat, 27 Jul 2024 16:25:44 -0400 X-MC-Unique: JFlVRlqNMdO8_Sl6Ee6iqw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7a1df704ef8so221635685a.2 for ; Sat, 27 Jul 2024 13:25:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722111943; x=1722716743; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JSEIA5vJGcmNG47dRgeUTjefyDTAllzG94evQ6NLUTk=; b=VDq2mycSFo6OUuPykmiuVBKHjSNORHsJzJcQxyN3Q/gduCdFFxxDRU6QR8aKpX/VkQ Oj1r0PIIN4MV2QWgRYrxMBrUk9TdMxd28eyaNdsMbDiyFhGax23bB2NvL7TfBjjWQnTa 9/yN6K3g7sXPXs9Ag7UXKbui7SWSEbE4ESXlubwh6J8VF60V9dREkz/GxvAuLgSiQQAC b/4qr290JeV6A9GNfqII7P/orSKUO2CH5fLaVxfSAefqUJFr4PP/zAkWg/3weemDrVtw U0DE4Wb9ttPDmJCxzhdOulfVOw5yknZXegyRJ4duBgWqAhbwYH2uSSJ2ODmy9ZVnJcAM BshA== X-Gm-Message-State: AOJu0YxHo/rVYcWRviyglvj1mranuvQCEEwgHb97i6gRy3JjeaIb5Bt0 wkvsmTd2uixBOHNs3lGExcWhhCmy8Fs4ToZvE8FP7umpdfzWEgrRvqNkIO32SoYZz5XEBqaPWfl I97Lmz/RFN2w77+uiNSzfYi7e28N5il0cQeTIsptj8cnDsPQ0ELxJ1AAKgpj3nL1N+SLxNT69e8 yU1lGWSrnkfFkz2Kg2lmcK0f6S3iyu59XkagI= X-Received: by 2002:a05:620a:3726:b0:79c:119e:2b44 with SMTP id af79cd13be357-7a1e522f965mr485231585a.3.1722111942957; Sat, 27 Jul 2024 13:25:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMRsbVLCZMQvc/KjKtKCrqeOkCfMxBrH/QgQCrzs7IXos+rnF7pcYpt/b/4/BRCRaIgfF2pw== X-Received: by 2002:a05:620a:3726:b0:79c:119e:2b44 with SMTP id af79cd13be357-7a1e522f965mr485229385a.3.1722111942436; Sat, 27 Jul 2024 13:25:42 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1e93765c1sm108590885a.119.2024.07.27.13.25.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jul 2024 13:25:41 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: improve C++ testsuite default versions Date: Sat, 27 Jul 2024 16:25:27 -0400 Message-ID: <20240727202540.3933690-1-jason@redhat.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- I wanted to add more cases to the setting of std_list in g++-dg.exp, but didn't want to do a full scan through the file for each case. So this patch improves that in two ways: first, by extracting all interesting lines on a single pass; second, by generating the list more flexibly: now we test every version mentioned explicitly in the testcase, plus a few more if fewer than three are mentioned. This also lowers changes from testing four to three versions for most testcases: the current default and the earliest and latest versions. This will reduce testing of C++14 and C++20 modes, and increase testing of C++26 mode. C++ front-end developers are encouraged to set the GXX_TESTSUITE_STDS environment variable to test more modes. gcc/testsuite/ChangeLog: * lib/gcc-dg.exp (get_matching_lines): New. * lib/g++-dg.exp: Improve std_list selection. --- gcc/testsuite/lib/g++-dg.exp | 45 +++++++++++++++++++++++++----------- gcc/testsuite/lib/gcc-dg.exp | 13 +++++++++++ 2 files changed, 44 insertions(+), 14 deletions(-) base-commit: 928116e94a5a8a995dffd926af58abfa7286e78e diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp index 52fba75c4a3..991be4d3867 100644 --- a/gcc/testsuite/lib/g++-dg.exp +++ b/gcc/testsuite/lib/g++-dg.exp @@ -53,21 +53,38 @@ proc g++-dg-runtest { testcases flags default-extra-flags } { if { [llength $gpp_std_list] > 0 } { set std_list $gpp_std_list } else { - # If the test requires a newer C++ version than which - # is tested by default, use that C++ version for that - # single test. Or if a test checks behavior specifically for - # one C++ version, include that version in the default list. - # These should be adjusted whenever the default std_list is - # updated or newer C++ effective target is added. - if [search_for $test "\{ dg-do * \{ target c++23"] { - set std_list { 23 26 } - } elseif [search_for $test "\{ dg-do * \{ target c++26"] { - set std_list { 26 } - } elseif [search_for $test "c++11_only"] { - set std_list { 98 11 14 20 } - } else { - set std_list { 98 14 17 20 } + # If the test mentions specific C++ versions, test those. + set lines [get_matching_lines $test {\{ dg* c++[0-9][0-9]}] + set std_list {} + set low 0 + foreach line $lines { + regexp {c\+\+([0-9][0-9])} $line -> ver + lappend std_list $ver + + if { $ver == 98 } { + # Leave low alone. + } elseif { [regexp {dg-do|dg-require-effective-target} $line] } { + set low $ver + } } + #verbose "low: $low" 1 + + set std_list [lsort -unique $std_list] + + # If fewer than 3 specific versions are mentioned, add more. + # The order of this list is significant: first $cxx_default, + # then the oldest and newest, then others in rough order of + # importance based on test coverage and usage. + foreach ver { 17 98 26 11 20 14 23 } { + set cmpver $ver + if { $ver == 98 } { set cmpver 03 } + if { [llength $std_list] < 3 + && $ver ni $std_list + && $cmpver > $low } { + lappend std_list $ver + } + } + verbose "std_list: $std_list" 1 } set option_list { } foreach x $std_list { diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 228c21d1207..992062103c1 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -574,6 +574,19 @@ proc search_for { file pattern } { return 0 } +# get_matching_lines -- return a list of matching lines in file +proc get_matching_lines { file pattern } { + set lines {} + set fd [open $file r] + while { [gets $fd cur_line]>=0 } { + if [string match "*$pattern*" $cur_line] then { + lappend lines $cur_line + } + } + close $fd + return $lines +} + # Modified dg-runtest that can cycle through a list of optimization options # as c-torture does. proc gcc-dg-runtest { testcases flags default-extra-flags } {