@@ -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 {
@@ -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 } {