]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use global variables for default/max std in libstdc++.exp
authorJonathan Wakely <jwakely@redhat.com>
Tue, 17 Feb 2026 12:48:51 +0000 (12:48 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 19 Feb 2026 14:50:58 +0000 (14:50 +0000)
This simplifies the v3-minimum-std procedure slightly, but the main
advantage is making v3_modules_std depend on v3_max_std so that we don't
have to update two separate variables when new effective targets such as
c++29 get added.

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (v3_default_std, v3_max_std): New
global variables.
(v3-minimum-std): Use globals instead of arguments.
(v3_modules_std): Define in terms of $v3_max_std.
(v3-dg-runtest): Use globals instead of local variables. Adjust
call to v3-min-std.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/testsuite/lib/libstdc++.exp

index 5b50972511f36554add7ef0d2779b2821c7e624c..d2d61a9bed9ccaf1c39691de60111b19ffdfb9b0 100644 (file)
@@ -473,9 +473,16 @@ if { [info procs saved-dg-test] == [list] } {
     }
 }
 
+# These should be adjusted whenever the compiler's default -std is updated
+# or a newer C++ effective target is added.
+set v3_default_std 20
+set v3_max_std 26
+
 # Find the minimum standard required by a test, if higher than the default_std.
 proc v3-minimum-std { test default_std max_std } {
-    for {set s $default_std} {$s <= $max_std} {incr s 3} {
+    global v3_default_std
+    global v3_max_std
+    for {set s $default_std} {$s <= $v3_max_std} {incr s 3} {
        if [search_for $test "\{ dg-do * \{ target c++$s"] {
            return $s
        } elseif [search_for $test "\{ dg-require-effective-target c++$s"] {
@@ -496,13 +503,15 @@ if [info exists env(GLIBCXX_TESTSUITE_STDS)] {
 
 # Allow adjusting which -std we test with -fmodules.
 if ![info exists v3_modules_std] {
-    set v3_modules_std "26"
+    set v3_modules_std "$v3_max_std"
 }
 
 # Modified dg-runtest that runs tests in multiple standard modes,
 # unless they specifically specify one standard.
 proc v3-dg-runtest { testcases flags default-extra-flags } {
     global runtests
+    global v3_default_std
+    global v3_max_std
     global v3_modules_std
 
     foreach test $testcases {
@@ -529,22 +538,18 @@ proc v3-dg-runtest { testcases flags default-extra-flags } {
                # If the test requires a newer C++ version than which
                # is tested by default, use that C++ version for that
                # single test.
-               # These should be adjusted whenever the default -std is
-               # updated or newer C++ effective target is added.
-               set default_std 20
-               set max_std 26
-               set min_std [v3-minimum-std $test $default_std $max_std]
-               if { $min_std > $default_std } {
+               set min_std [v3-minimum-std $test]
+               if { $min_std > $v3_default_std } {
                    set std_list $min_std
-                   if { $min_std != $max_std } {
+                   if { $min_std != $v3_max_std } {
                        # Also test the latest version.
-                       lappend std_list "$max_std"
+                       lappend std_list "$v3_max_std"
                    }
                } else {
                    # Only run each test once with the default -std option.
                    # This avoids increasing the run time for most testers.
                    # Libstdc++ developers can override this with v3_std_list.
-                   set std_list $default_std
+                   set std_list $v3_default_std
                }
            }
            set option_list { }