https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114384

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #0)
> While trying to understand how to use `{ target c++20 }` option to dg-do I
> noticed it is not documented in the internals manual (sourcebuild.texi)
> while all other target support options are there.
> 
> It would be useful to have this documented because the rules seems to get
> complex if you have a testcase which says works one way for C++11 to C++14
> but works another way for C++98 and C++17+.

That seems extremely unlikely in practice :-)

> 
> Where is it valid to place these targets

It's an effective-target keyword, so you can use it anywhere those are used.

> and even how to describe the above
> would be very useful. Do we need 3 testcases, one for pre C++11, one for
> C++11/C++14 and one for C++17+ ?

No, you could use { target { c++11 && c++14_down } }


c++NN means that standard and later

c++NN_down means that standard and earlier

c++NN_only means exactly what it says

The current test flags are inspected to see which -std is in effect for the
test, and if no -std is present, it assumes the default set by:
set cxx_default "c++17"

Those effective target keywords check the -std option in effect and decide
whether the test should be run or skipped.


By default, each g++ test is run multiple times with different -std options,
which will get compared to the effective-target keywords each time. The set of
tests to run is controllable by the user via:

set gpp_compile_options ""
# Allow gpp_std_list to be set in configuration files, e.g., ~/.dejagnurc
if ![info exists gpp_std_list] {
    set gpp_std_list { }
}
# Allow gpp_std_list to be set from the environment.
if [info exists env(GXX_TESTSUITE_STDS)] {
    set gpp_std_list [split $env(GXX_TESTSUITE_STDS) ","]
}

That gpp_std_list is used by g++-dg-runtest in g++-dg.exp, and if the list is
empty, the default set depends on the test:

            # See g++.exp for the initial value of this list.
            global gpp_std_list
            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 }
                }
            }


(In reply to Andrew Pinski from comment #1)
> Oh and how it interacts with -std=gnu++17 vs -std=c++17 (etc.).

For g++ that seems to be controlled by the presence of any dg-options
directive:

            if [search_for $test "dg-options"] {
                set std_prefix "-std=gnu++"
            } else {
                set std_prefix "-std=c++"
            }

Reply via email to