diff options
author | Jason Merrill <jason@redhat.com> | 2024-07-26 15:10:50 -0400 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2024-07-28 19:06:02 +0200 |
commit | 557373c0cd6c0d6b4a1e46dc7a53d929b60b3c9b (patch) | |
tree | 792226ac6e8ff7de3a8eafbd3d3099c1b7486989 | |
parent | 262163238006aa39eff5ebd8283ec7254161269a (diff) | |
download | gcc-557373c0cd6c0d6b4a1e46dc7a53d929b60b3c9b.zip gcc-557373c0cd6c0d6b4a1e46dc7a53d929b60b3c9b.tar.gz gcc-557373c0cd6c0d6b4a1e46dc7a53d929b60b3c9b.tar.bz2 |
c++: improve C++ testsuite default versions
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.
-rw-r--r-- | gcc/testsuite/lib/g++-dg.exp | 45 | ||||
-rw-r--r-- | gcc/testsuite/lib/gcc-dg.exp | 13 |
2 files changed, 44 insertions, 14 deletions
diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp index 52fba75..991be4d 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 228c21d..9920621 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 } { |