From 79d38dd46e6b07e5a90ab25df1438eb0918eb475 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 19 Oct 2022 18:55:46 +0200 Subject: 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 * 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. --- gcc/testsuite/lib/g++-dg.exp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp index 59e8081..9bf63a1 100644 --- a/gcc/testsuite/lib/g++-dg.exp +++ b/gcc/testsuite/lib/g++-dg.exp @@ -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 { -- cgit v1.1