public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: "François Dumont" <frs.dumont@gmail.com>
To: Alexandre Oliva <oliva@adacore.com>, libstdc++@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org, Corentin Gay <gay@adacore.com>
Subject: Re: Add dg-require-wchars to libstdc++ testsuite
Date: Mon, 28 Dec 2020 19:27:05 +0100	[thread overview]
Message-ID: <f6daefae-c7d2-8b39-c4af-6b1866355105@gmail.com> (raw)
In-Reply-To: <orwnx9ilza.fsf@lxoliva.fsfla.org>

On 22/12/20 10:12 pm, Alexandre Oliva wrote:
> Some tests uses structures from the libstdc++ that are present only if
> the target has a wchar.h header.  However, those tests do not check
> that the target supports those constructs before executing the tests.

Like you already spotted in another thread those tests should be in some 
sub-folder containing 'wchar_t' to be considered as UNSUP.

Maybe Jonathan will prefer them to be moved even if your approach seems 
more convenient to me.


>
> The function dg-require-wchars checks that "_GLIBCXX_USE_WCHAR_T" is
> defined by the configure of the libstdc++.  If it is not the case, the
> test is not executed.
>
> Regstrapped on x86_64-linux-gnu, and tested with -x-arm-wrs-vxworks7r2.
> Ok to install?
>
>
> from Corentin Gay <gay@adacore.com>
> for  libstdc++-v3/ChangeLog
>
> 	* testsuite/lib/dg-options.exp: Add dg-require-wchars
> 	function.
> 	* testsuite/lib/libstdc++.exp: Add check_v3_target_wchars
> 	function.
> 	* testsuite/22_locale/codecvt/codecvt_utf16/79980.cc: Add
> 	requirement.
> 	* testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc:
> 	Likewise.
> 	* testsuite/22_locale/codecvt/codecvt_utf8/79980.cc: Likewise.
> 	* testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc:
> 	Likewise.
> 	* testsuite/22_locale/conversions/buffer/1.cc: Likewise.
> 	* testsuite/22_locale/conversions/buffer/2.cc: Likewise.
> 	* testsuite/22_locale/conversions/buffer/3.cc: Likewise.
> 	* testsuite/22_locale/conversions/buffer/requirements/typedefs.cc:
> 	Likewise.
> 	* testsuite/22_locale/conversions/string/1.cc: Likewise.
> 	* testsuite/22_locale/conversions/string/2.cc: Likewise.
> 	* testsuite/22_locale/conversions/string/3.cc: Likewise.
> 	* testsuite/22_locale/conversions/string/66441.cc: Likewise.
> 	* testsuite/22_locale/conversions/string/requirements/typedefs.cc:
> 	Likewise.
> 	* testsuite/22_locale/conversions/string/requirements/typedefs-2.cc:
> 	Likewise.
> ---
>   .../22_locale/codecvt/codecvt_utf16/79980.cc       |    1
>   .../22_locale/codecvt/codecvt_utf16/misaligned.cc  |    1
>   .../22_locale/codecvt/codecvt_utf8/79980.cc        |    1
>   .../22_locale/codecvt/codecvt_utf8_utf16/79511.cc  |    1
>   .../testsuite/22_locale/conversions/buffer/1.cc    |    1
>   .../testsuite/22_locale/conversions/buffer/2.cc    |    1
>   .../testsuite/22_locale/conversions/buffer/3.cc    |    1
>   .../conversions/buffer/requirements/typedefs.cc    |    1
>   .../testsuite/22_locale/conversions/string/1.cc    |    1
>   .../testsuite/22_locale/conversions/string/2.cc    |    1
>   .../testsuite/22_locale/conversions/string/3.cc    |    1
>   .../22_locale/conversions/string/66441.cc          |    1
>   .../conversions/string/requirements/typedefs-2.cc  |    1
>   .../conversions/string/requirements/typedefs.cc    |    1
>   libstdc++-v3/testsuite/lib/dg-options.exp          |    9 ++++
>   libstdc++-v3/testsuite/lib/libstdc++.exp           |   47 ++++++++++++++++++++
>   16 files changed, 70 insertions(+)
>
> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc
> index 8a092913a4c92..039bdd0322907 100644
> --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc
> +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc
> @@ -16,6 +16,7 @@
>   // <http://www.gnu.org/licenses/>.
>   
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   #include <locale>
>   #include <codecvt>
> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc
> index 04cfc8d744bdd..3496e0e819e98 100644
> --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc
> +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/misaligned.cc
> @@ -16,6 +16,7 @@
>   // <http://www.gnu.org/licenses/>.
>   
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   #include <locale>
>   #include <codecvt>
> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc
> index 68ae5af234ae5..fd69dd5c04de0 100644
> --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc
> +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/79980.cc
> @@ -16,6 +16,7 @@
>   // <http://www.gnu.org/licenses/>.
>   
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   #include <codecvt>
>   #include <locale>
> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc
> index 1f63e7218e7d2..590a3b73bfc41 100644
> --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc
> +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/79511.cc
> @@ -16,6 +16,7 @@
>   // <http://www.gnu.org/licenses/>.
>   
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   #include <locale>
>   #include <codecvt>
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc
> index 2855f7432d464..91bf2bf22160d 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc
> @@ -1,4 +1,5 @@
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // Copyright (C) 2015-2020 Free Software Foundation, Inc.
>   //
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/2.cc b/libstdc++-v3/testsuite/22_locale/conversions/buffer/2.cc
> index 2cf320fc13cca..a03a16a02ed0b 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/2.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/2.cc
> @@ -16,6 +16,7 @@
>   // <http://www.gnu.org/licenses/>.
>   
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   #include <locale>
>   #include <sstream>
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc b/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc
> index de43e0a95b2b7..84d5358f4999c 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/3.cc
> @@ -16,6 +16,7 @@
>   // <http://www.gnu.org/licenses/>.
>   
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   #include <locale>
>   #include <streambuf>
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/requirements/typedefs.cc b/libstdc++-v3/testsuite/22_locale/conversions/buffer/requirements/typedefs.cc
> index e88799dbec750..8efe203e87398 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/requirements/typedefs.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/requirements/typedefs.cc
> @@ -1,4 +1,5 @@
>   // { dg-do compile { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // Copyright (C) 2015-2020 Free Software Foundation, Inc.
>   //
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc
> index 41d6594fe1320..d491e6c52709e 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc
> @@ -1,4 +1,5 @@
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // Copyright (C) 2015-2020 Free Software Foundation, Inc.
>   //
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/2.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/2.cc
> index bc26e328a6039..b4867053f3c85 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/string/2.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/2.cc
> @@ -1,4 +1,5 @@
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // Copyright (C) 2015-2020 Free Software Foundation, Inc.
>   //
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/3.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/3.cc
> index b7793cdca49ea..023897c9307b5 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/string/3.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/3.cc
> @@ -1,4 +1,5 @@
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // Copyright (C) 2015-2020 Free Software Foundation, Inc.
>   //
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc
> index 07136aec1179e..b78c31fbb9b1b 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/66441.cc
> @@ -16,6 +16,7 @@
>   // <http://www.gnu.org/licenses/>.
>   
>   // { dg-do run { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // libstdc++/66441
>   
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs-2.cc
> index 91b47c449a16a..4cd254a40da57 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs-2.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs-2.cc
> @@ -1,4 +1,5 @@
>   // { dg-do compile { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // Copyright (C) 2015-2020 Free Software Foundation, Inc.
>   //
> diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs.cc
> index 023caa69a6e3a..30e49b2ff893b 100644
> --- a/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs.cc
> +++ b/libstdc++-v3/testsuite/22_locale/conversions/string/requirements/typedefs.cc
> @@ -1,4 +1,5 @@
>   // { dg-do compile { target c++11 } }
> +// { dg-require-wchars "" }
>   
>   // Copyright (C) 2015-2020 Free Software Foundation, Inc.
>   //
> diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp
> index 0102acf65a282..17306a0eb0205 100644
> --- a/libstdc++-v3/testsuite/lib/dg-options.exp
> +++ b/libstdc++-v3/testsuite/lib/dg-options.exp
> @@ -16,6 +16,15 @@
>   # along with this program; see the file COPYING3.  If not see
>   # <http://www.gnu.org/licenses/>.
>   
> +proc dg-require-wchars { args } {
> +    if { ![ check_v3_target_wchars ] } {
> +	upvar dg-do-what dg-do-what
> +	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
> +	return
> +    }
> +    return
> +}
> +
>   proc dg-require-c-std { args } {
>       if { ![ check_v3_target_c_std ] } {
>   	upvar dg-do-what dg-do-what
> diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
> index b7d7b906de41c..2c22bcc0f0c94 100644
> --- a/libstdc++-v3/testsuite/lib/libstdc++.exp
> +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
> @@ -702,6 +702,53 @@ proc v3-build_support { } {
>       }
>   }
>   
> +proc check_v3_target_wchars { } {
> +    global et_wchars
> +    global et_wchars_target_name
> +    global tool
> +
> +    if { ![info exists et_wchars_target_name] } {
> +	set et_wchars_target_name ""
> +    }
> +
> +    # If the target has changed since we set the cached value, clear it.
> +    set current_target [current_target_name]
> +    if { $current_target != $et_wchars_target_name } {
> +	verbose "check_v3_target_wchars: `$et_wchars_target_name'" 2
> +	set et_wchars_target_name $current_target
> +	if [info exists et_wchars] {
> +	    verbose "check_v3_target_wchars: removing cached result" 2
> +	    unset et_wchars
> +	}
> +    }
> +
> +    if [info exists et_wchars] {
> +	verbose "check_v3_target_wchars: using cached result" 2
> +    } else {
> +	set et_wchars 0
> +
> +	# Set up and preprocess a C++ test program that depends
> +	# on wchars support being configured in the libstdc++.
> +	set src wchars[pid].cc
> +
> +	set f [open $src "w"]
> +	puts $f "#ifndef _GLIBCXX_USE_WCHAR_T"
> +	puts $f "#  error No wchar header."
> +	puts $f "#endif"
> +	close $f
> +
> +	set lines [v3_target_compile $src /dev/null preprocess ""]
> +	file delete $src
> +
> +	if [string match "" $lines] {
> +	    # No error message, preprocessing succeeded.
> +	    set et_wchars 1
> +	}
> +    }
> +    verbose "check_v3_target_wchars: $et_wchars" 2
> +    return $et_wchars
> +}
> +

This check_v3_target_wchars looks like a good candidate to leverage on: 
v3_check_preprocessor_condition.



  parent reply	other threads:[~2020-12-28 18:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 21:12 Alexandre Oliva
2020-12-28 18:23 ` François Dumont
2021-01-13 17:29   ` Alexandre Oliva
2021-01-14 13:08     ` Jonathan Wakely
2020-12-28 18:27 ` François Dumont [this message]
2021-01-14 13:41 ` Jonathan Wakely
2021-01-14 13:47   ` Add dg-require-wchars to libstdc++ testsuite# Jonathan Wakely
2021-01-14 22:20   ` Add dg-require-wchars to libstdc++ testsuite Alexandre Oliva
2021-01-15 10:09     ` Jonathan Wakely
2021-01-15 16:18       ` Alexandre Oliva
2021-01-15 19:47         ` Jonathan Wakely
2021-10-09  7:31           ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f6daefae-c7d2-8b39-c4af-6b1866355105@gmail.com \
    --to=frs.dumont@gmail.com \
    --cc=gay@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=oliva@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).