testsuite: Default make check-g++ vs. tests for newest C++ standard

When adding tests for upcoming C++ version, one always has a dilemma
whether to use explicit // { dg-options "-std=c++2b" }
or -std=gnu++2b and similar, then the test works in all modes, but it might
be forgotten later on to be converted into // { dg-do whatever { target c++23 } }
test so that when 23 is tested by default and say 26 or 29 appears too,
we test it also in those modes, or just go with
// { dg-do whatever { target c++23 } }
which has the disadvantage that it is skipped when testing by default and
one only tests it if he asks for the newer version.

The following patch changes it, such that it is safe to add
// { dg-do whatever { target c++23 } }
style tests and make those tested even in the default testing mode
(when GXX_TESTSUITE_STDS or check-c++-all etc. aren't used).
This is by searching for such dg-do lines and if there is an effective
target newer than the latest by default tested language version, it will
just use that language version instead of the default list.
Without this change, the test would be UNSUPPORTED in currently
all of 98 14 17 20 versions, with the patch it will be tested with a single
23 version.

2022-10-19  Jakub Jelinek  <jakub@redhat.com>

	* lib/g++-dg.exp (g++-dg-runtest): When using defaulted
	std_list, if test has { dg-do * { target c++23 } } directive,
	use { 23 } with which the test will run instead of { 98 14 17 20 }
	which would make it UNSUPPORTED in all cases.
This commit is contained in:
Jakub Jelinek 2022-10-19 18:55:46 +02:00
parent a10d6b5eb9
commit 79d38dd46e

View file

@ -53,7 +53,16 @@ proc g++-dg-runtest { testcases flags default-extra-flags } {
if { [llength $gpp_std_list] > 0 } {
set std_list $gpp_std_list
} else {
set std_list { 98 14 17 20 }
# If the test requires a newer C++ version than which
# is tested by default, use that C++ version for that
# single test. This should be updated or commented
# out 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 }
} else {
set std_list { 98 14 17 20 }
}
}
set option_list { }
foreach x $std_list {