public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Add dg-require-wchars to libstdc++ testsuite
@ 2020-12-22 21:12 Alexandre Oliva
  2020-12-28 18:23 ` François Dumont
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Alexandre Oliva @ 2020-12-22 21:12 UTC (permalink / raw)
  To: libstdc++; +Cc: Corentin Gay, gcc-patches


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.

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
+}
+
 # Implement an target check for property PROP by invoking
 # the Tcl command ARGS and seeing if it returns true.
 


-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist         GNU Toolchain Engineer
        Vim, Vi, Voltei pro Emacs -- GNUlius Caesar

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2020-12-22 21:12 Add dg-require-wchars to libstdc++ testsuite Alexandre Oliva
@ 2020-12-28 18:23 ` François Dumont
  2021-01-13 17:29   ` Alexandre Oliva
  2020-12-28 18:27 ` François Dumont
  2021-01-14 13:41 ` Jonathan Wakely
  2 siblings, 1 reply; 12+ messages in thread
From: François Dumont @ 2020-12-28 18:23 UTC (permalink / raw)
  To: Alexandre Oliva, libstdc++; +Cc: gcc-patches, Corentin Gay

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.

Looks like 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.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2020-12-22 21:12 Add dg-require-wchars to libstdc++ testsuite Alexandre Oliva
  2020-12-28 18:23 ` François Dumont
@ 2020-12-28 18:27 ` François Dumont
  2021-01-14 13:41 ` Jonathan Wakely
  2 siblings, 0 replies; 12+ messages in thread
From: François Dumont @ 2020-12-28 18:27 UTC (permalink / raw)
  To: Alexandre Oliva, libstdc++; +Cc: gcc-patches, Corentin Gay

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.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2020-12-28 18:23 ` François Dumont
@ 2021-01-13 17:29   ` Alexandre Oliva
  2021-01-14 13:08     ` Jonathan Wakely
  0 siblings, 1 reply; 12+ messages in thread
From: Alexandre Oliva @ 2021-01-13 17:29 UTC (permalink / raw)
  To: François Dumont, Jonathan Wakely
  Cc: libstdc++, gcc-patches, Corentin Gay

On Dec 28, 2020, François Dumont <frs.dumont@gmail.com> wrote:

> 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.

> Looks like 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.

I'd be glad to make such changes, but I'd appreciate stronger guidance
as to the preferences and the way to go before doing so.  Jonathan,
would you please share your wisdom WRT this patch and the other
wchar_t-related libstdc++ testsuite one?

https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562435.html
https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562438.html

>> 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.

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

Nice!, thanks for the tip, I was not aware of this proc.

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist         GNU Toolchain Engineer
        Vim, Vi, Voltei pro Emacs -- GNUlius Caesar

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2021-01-13 17:29   ` Alexandre Oliva
@ 2021-01-14 13:08     ` Jonathan Wakely
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2021-01-14 13:08 UTC (permalink / raw)
  To: Alexandre Oliva
  Cc: François Dumont, Jonathan Wakely, libstdc++,
	gcc-patches, Corentin Gay

On 13/01/21 14:29 -0300, Alexandre Oliva wrote:
>On Dec 28, 2020, François Dumont <frs.dumont@gmail.com> wrote:
>
>> 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.
>
>> Looks like 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.
>
>I'd be glad to make such changes, but I'd appreciate stronger guidance
>as to the preferences and the way to go before doing so.  Jonathan,
>would you please share your wisdom WRT this patch and the other
>wchar_t-related libstdc++ testsuite one?
>
>https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562435.html
>https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562438.html

I'll look at them today.

>>> 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.
>
>> This check_v3_target_wchars looks like a good candidate to leverage
>> on: v3_check_preprocessor_condition.
>
>Nice!, thanks for the tip, I was not aware of this proc.

It's only been there a few weeks.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2020-12-22 21:12 Add dg-require-wchars to libstdc++ testsuite Alexandre Oliva
  2020-12-28 18:23 ` François Dumont
  2020-12-28 18:27 ` François Dumont
@ 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
  2 siblings, 2 replies; 12+ messages in thread
From: Jonathan Wakely @ 2021-01-14 13:41 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: libstdc++, gcc-patches, Corentin Gay

[-- Attachment #1: Type: text/plain, Size: 3992 bytes --]

On 22/12/20 18:12 -0300, Alexandre Oliva wrote:
>--- 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 "" }

This test doesn't use wchar_t, so it shouldn't depend on
_GLIBCXX_USE_WCHAR_T being defined.

The problem is that <bits/locale_conv.h> uses wchar_t in default
template arguments:

#ifdef _GLIBCXX_USE_WCHAR_T

_GLIBCXX_BEGIN_NAMESPACE_CXX11

   /// String conversions
   template<typename _Codecvt, typename _Elem = wchar_t,

That makes it impossible to use wstring_convert and wbuffer_convert
without wchar_t, even if you don't want to convert to wchar_t.

I think we should fix the header, not disable tests that don't use
that default template argument. The attached patch should allow you to
use wstring_convert and wbuffer_convert without wchar_t support. The
tests which instantiate it with char16_t or char32_t instead of
wchar_t should work with this patch, right?

<aside>
Is it the case that the wchar_t type is defined on this target, it's
just that libc doesn't have support for wcslen etc?  Because we should
probably audit all our uses of _GLIBCXX_USE_WCHAR_T and find which
ones actually need libc support and which just need the wchar_t type
to exist. Some things really do need the libc support, but I suspect
many others don't.

It seems wrong that we can provide full support for char16_t and
char32_t but not wchar_t, just because the former two don't depend on
anything being present in libc. Why can't we just implement the same
functionality for wchar_t without using libc?

In fact, if we just define std::char_traits<wchar_t> generically
without using any libc functions (or just using them as optimisations)
we might be able to support std::basic_string<wchar_t> and iostream
classes with almost no work. But that's something to consider in the
future.
</aside>

>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."

As François said, this could use the new proc. I'd also prefer if it
was defined as an effective-target keyword so we can use:

// { dg-require-effective-target wchars }

instead of the old fashioned { dg-require-wchars "" } form. I've
recently added effective-target keywords for several of the
dg-require-FOO directives, so we can move away from the old form. I
think new directives should be done as effective-target keywords. See
the recent changes to libstdc++-v3/testsuite/lib/libstdc++.exp for
examples, e.g. 10ee46adf44ae731fc4f9e9fdc25ad60c9d43a9c

But we might not even need this new proc if the codecvt tests can be
made to work using the attached patch.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1470 bytes --]

diff --git a/libstdc++-v3/include/bits/locale_conv.h b/libstdc++-v3/include/bits/locale_conv.h
index 0e409da9876..d8a4d0851f4 100644
--- a/libstdc++-v3/include/bits/locale_conv.h
+++ b/libstdc++-v3/include/bits/locale_conv.h
@@ -222,11 +222,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif  // _GLIBCXX_USE_CHAR8_T
 
 #ifdef _GLIBCXX_USE_WCHAR_T
+# define _GLIBCXX_WCHAR_DEFAULT_TEMPL_ARG = wchar_t
+#else
+// wstring_convert and wbuffer_convert are still defined for targets without
+// wchar_t support, but the second template argument must be given explictly.
+# define _GLIBCXX_WCHAR_DEFAULT_TEMPL_ARG
+#endif
 
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
   /// String conversions
-  template<typename _Codecvt, typename _Elem = wchar_t,
+  template<typename _Codecvt, typename _Elem _GLIBCXX_WCHAR_DEFAULT_TEMPL_ARG,
 	   typename _Wide_alloc = allocator<_Elem>,
 	   typename _Byte_alloc = allocator<char>>
     class wstring_convert
@@ -382,7 +388,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_CXX11
 
   /// Buffer conversions
-  template<typename _Codecvt, typename _Elem = wchar_t,
+  template<typename _Codecvt, typename _Elem _GLIBCXX_WCHAR_DEFAULT_TEMPL_ARG,
 	   typename _Tr = char_traits<_Elem>>
     class wbuffer_convert : public basic_streambuf<_Elem, _Tr>
     {
@@ -606,8 +612,6 @@ _GLIBCXX_END_NAMESPACE_CXX11
       bool			_M_always_noconv;
     };
 
-#endif  // _GLIBCXX_USE_WCHAR_T
-
   /// @} group locales
 
 _GLIBCXX_END_NAMESPACE_VERSION

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite#
  2021-01-14 13:41 ` Jonathan Wakely
@ 2021-01-14 13:47   ` Jonathan Wakely
  2021-01-14 22:20   ` Add dg-require-wchars to libstdc++ testsuite Alexandre Oliva
  1 sibling, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2021-01-14 13:47 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: libstdc++, gcc-patches, Corentin Gay

[-- Attachment #1: Type: text/plain, Size: 1336 bytes --]

On 14/01/21 13:41 +0000, Jonathan Wakely wrote:
><aside>
>Is it the case that the wchar_t type is defined on this target, it's
>just that libc doesn't have support for wcslen etc?  Because we should
>probably audit all our uses of _GLIBCXX_USE_WCHAR_T and find which
>ones actually need libc support and which just need the wchar_t type
>to exist. Some things really do need the libc support, but I suspect
>many others don't.
>
>It seems wrong that we can provide full support for char16_t and
>char32_t but not wchar_t, just because the former two don't depend on
>anything being present in libc. Why can't we just implement the same
>functionality for wchar_t without using libc?
>
>In fact, if we just define std::char_traits<wchar_t> generically
>without using any libc functions (or just using them as optimisations)
>we might be able to support std::basic_string<wchar_t> and iostream
>classes with almost no work. But that's something to consider in the
>future.
></aside>

Oops, I considered it already.

This untested patch should define std::char_traits<wchar_t> so it is
available if wchar_t is defined by the front end (which I assume is
always true, is that right?), only using optimized libc routines if
available.

This would be the first step to enabling std::wstring etc for targets
with no wchar_t support in libc.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3820 bytes --]

diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index ea1e036f721..3a60478ea32 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -438,7 +438,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 
 
-#ifdef _GLIBCXX_USE_WCHAR_T
+#ifdef __SIZEOF_WCHAR_T__
   /// 21.1.3.2  char_traits specializations
   template<>
     struct char_traits<wchar_t>
@@ -469,23 +469,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	if (__n == 0)
 	  return 0;
-#if __cplusplus >= 201703L
-	if (__builtin_constant_p(__n)
-	    && __constant_char_array_p(__s1, __n)
-	    && __constant_char_array_p(__s2, __n))
-	  return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
+#ifdef _GLIBCXX_USE_WCHAR_T
+	if (!__builtin_is_constant_evaluated())
+	  return wmemcmp(__s1, __s2, __n);
 #endif
-	return wmemcmp(__s1, __s2, __n);
+	return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
       }
 
       static _GLIBCXX17_CONSTEXPR size_t
       length(const char_type* __s)
       {
-#if __cplusplus >= 201703L
-	if (__constant_string_p(__s))
-	  return __gnu_cxx::char_traits<char_type>::length(__s);
+#ifdef _GLIBCXX_USE_WCHAR_T
+	if (!__builtin_is_constant_evaluated())
+	  return wcslen(__s);
 #endif
-	return wcslen(__s);
+	return __gnu_cxx::char_traits<char_type>::length(__s);
       }
 
       static _GLIBCXX17_CONSTEXPR const char_type*
@@ -493,13 +491,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	if (__n == 0)
 	  return 0;
-#if __cplusplus >= 201703L
-	if (__builtin_constant_p(__n)
-	    && __builtin_constant_p(__a)
-	    && __constant_char_array_p(__s, __n))
-	  return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
+#ifdef _GLIBCXX_USE_WCHAR_T
+	if (!__builtin_is_constant_evaluated())
+	  return wmemchr(__s, __a, __n);
 #endif
-	return wmemchr(__s, __a, __n);
+	return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
       }
 
       static _GLIBCXX20_CONSTEXPR char_type*
@@ -507,11 +503,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	if (__n == 0)
 	  return __s1;
-#ifdef __cpp_lib_is_constant_evaluated
-	if (std::is_constant_evaluated())
-	  return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
+#ifdef _GLIBCXX_USE_WCHAR_T
+	if (!__builtin_is_constant_evaluated())
+	  return wmemmove(__s1, __s2, __n);
 #endif
-	return wmemmove(__s1, __s2, __n);
+	return __gnu_cxx::char_traits<char_type>::move(__s1, __s2, __n);
       }
 
       static _GLIBCXX20_CONSTEXPR char_type*
@@ -519,11 +515,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	if (__n == 0)
 	  return __s1;
-#ifdef __cpp_lib_is_constant_evaluated
-	if (std::is_constant_evaluated())
-	  return __gnu_cxx::char_traits<char_type>::copy(__s1, __s2, __n);
+#ifdef _GLIBCXX_USE_WCHAR_T
+	if (!__builtin_is_constant_evaluated())
+	  return wmemcpy(__s1, __s2, __n);
 #endif
-	return wmemcpy(__s1, __s2, __n);
+	return __gnu_cxx::char_traits<char_type>::copy(__s1, __s2, __n);
       }
 
       static _GLIBCXX20_CONSTEXPR char_type*
@@ -531,11 +527,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	if (__n == 0)
 	  return __s;
-#ifdef __cpp_lib_is_constant_evaluated
-	if (std::is_constant_evaluated())
-	  return __gnu_cxx::char_traits<char_type>::assign(__s, __n, __a);
+#ifdef _GLIBCXX_USE_WCHAR_T
+	if (!__builtin_is_constant_evaluated())
+	  return wmemset(__s, __a, __n);
 #endif
-	return wmemset(__s, __a, __n);
+	return __gnu_cxx::char_traits<char_type>::assign(__s, __n, __a);
       }
 
       static _GLIBCXX_CONSTEXPR char_type
@@ -558,7 +554,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT
       { return eq_int_type(__c, eof()) ? 0 : __c; }
   };
-#endif //_GLIBCXX_USE_WCHAR_T
+#endif // __SIZEOF_WCHAR_T__
 
 #ifdef _GLIBCXX_USE_CHAR8_T
   template<>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  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   ` Alexandre Oliva
  2021-01-15 10:09     ` Jonathan Wakely
  1 sibling, 1 reply; 12+ messages in thread
From: Alexandre Oliva @ 2021-01-14 22:20 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches, Corentin Gay

On Jan 14, 2021, Jonathan Wakely <jwakely@redhat.com> wrote:

> The problem is that <bits/locale_conv.h> uses wchar_t in default
> template arguments:

> I think we should fix the header, not disable tests that don't use
> that default template argument. The attached patch should allow you to
> use wstring_convert and wbuffer_convert without wchar_t support. The
> tests which instantiate it with char16_t or char32_t instead of
> wchar_t should work with this patch, right?

Thanks, I'll give it a spin.  That said, ...

> <aside>
> Is it the case that the wchar_t type is defined on this target, it's
> just that libc doesn't have support for wcslen etc?

... it is definitely the case that the target currently defines wchar_t,
and it even offers wchar.h and a lot of (maybe all?) wcs* functions.
This was likely not the case when the patch was first written.

I'll double check whether any of the patch is still needed for current
versions.

I figured it would a waste to just discard Corentin's identification of
testcases that failed when glibc wchar_t support was not enabled.

This also means that the test results I'm going to get are likely to not
reflect the conditions for which these patches were originally written.


FWIW, I like very much the notion of offering a fallback wchar_t
implementation within libstdc++-v3, so that users get the expected C++
functionality even when libc doesn't offer it.  Even a (conditional?)
typedef to introduce wchar_t could be there.

Perhaps the test that sets or clears _GLIBCXX_USE_WCHAR_T should be used
to decide whether or not to offer a wchar.h header in libstdc++, and
then (pipe dream?) all other uses of this macro would be just gone?


> As François said, this could use the new proc. I'd also prefer if it
> was defined as an effective-target keyword so we can use:

> // { dg-require-effective-target wchars }

*nod*


> But we might not even need this new proc if the codecvt tests can be
> made to work using the attached patch.

Thanks,

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist         GNU Toolchain Engineer
        Vim, Vi, Voltei pro Emacs -- GNUlius Caesar

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Wakely @ 2021-01-15 10:09 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: Jonathan Wakely, libstdc++, gcc-patches, Corentin Gay

On Thu, 14 Jan 2021, 22:22 Alexandre Oliva, <oliva@adacore.com> wrote:

> On Jan 14, 2021, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> > The problem is that <bits/locale_conv.h> uses wchar_t in default
> > template arguments:
>
> > I think we should fix the header, not disable tests that don't use
> > that default template argument. The attached patch should allow you to
> > use wstring_convert and wbuffer_convert without wchar_t support. The
> > tests which instantiate it with char16_t or char32_t instead of
> > wchar_t should work with this patch, right?
>
> Thanks, I'll give it a spin.  That said, ...
>
> > <aside>
> > Is it the case that the wchar_t type is defined on this target, it's
> > just that libc doesn't have support for wcslen etc?
>
> ... it is definitely the case that the target currently defines wchar_t,
> and it even offers wchar.h and a lot of (maybe all?) wcs* functions.
> This was likely not the case when the patch was first written.
>
> I'll double check whether any of the patch is still needed for current
> versions.
>
> I figured it would a waste to just discard Corentin's identification of
> testcases that failed when glibc wchar_t support was not enabled.
>

Definitely not a waste, as it's led to this discussion and plan for
improvement.



> This also means that the test results I'm going to get are likely to not
> reflect the conditions for which these patches were originally written.
>
>
> FWIW, I like very much the notion of offering a fallback wchar_t
> implementation within libstdc++-v3, so that users get the expected C++
> functionality even when libc doesn't offer it.  Even a (conditional?)
> typedef to introduce wchar_t could be there.
>
> Perhaps the test that sets or clears _GLIBCXX_USE_WCHAR_T should be used
> to decide whether or not to offer a wchar.h header in libstdc++, and
> then (pipe dream?) all other uses of this macro would be just gone?
>


That would be great. We might be able to get close even if not all the way
there. However, some small embedded systems might not want the extra
symbols for explicit instantiations of std::wstring, std::wistream in
libstdc++.so so we might want a way to suppress them (they could still
instantiate those templates implicitly by using them, we just wouldn't have
them pre-instantiated in the library).

Anyway, let's start just by making wstring_convert usable without wchar_t.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2021-01-15 10:09     ` Jonathan Wakely
@ 2021-01-15 16:18       ` Alexandre Oliva
  2021-01-15 19:47         ` Jonathan Wakely
  0 siblings, 1 reply; 12+ messages in thread
From: Alexandre Oliva @ 2021-01-15 16:18 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Jonathan Wakely, libstdc++, gcc-patches, Corentin Gay

On Jan 15, 2021, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:

> On Thu, 14 Jan 2021, 22:22 Alexandre Oliva, <oliva@adacore.com> wrote:
>> ... it is definitely the case that the target currently defines wchar_t,
>> and it even offers wchar.h and a lot of (maybe all?) wcs* functions.
>> This was likely not the case when the patch was first written.
>> 
>> I'll double check whether any of the patch is still needed for current
>> versions.

With the tests I've run since yesterday, I've determined that:

- the wchar-related patches for the libstdc++ testsuite, that I had
  proposed last year, are no longer needed

- your two patchlets did not bring about any regressions to test
  results, not in mainline x86_64-linux-gnu native, not with the trivial
  backports to the gcc-10 tree for x-arm-vxw7r2 that was the focus of my
  immediate attention.

So, I withdraw my submissions of the testsuite patches, and I encourage
you to proceed with the two changes you proposed.

However, for avoidance of any doubt, I'll restate that I cannot vow for
whether they're enough to fix the issues we'd run into back when
wchar/wcs* were not supported in the target system, because now they
are, so the changes do not bring any visible improvements to our results
either.

Anyway, thanks for the feedback!

-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist         GNU Toolchain Engineer
        Vim, Vi, Voltei pro Emacs -- GNUlius Caesar

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2021-01-15 16:18       ` Alexandre Oliva
@ 2021-01-15 19:47         ` Jonathan Wakely
  2021-10-09  7:31           ` Jonathan Wakely
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Wakely @ 2021-01-15 19:47 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: Jonathan Wakely, libstdc++, gcc-patches, Corentin Gay

On Fri, 15 Jan 2021, 16:19 Alexandre Oliva, <oliva@adacore.com> wrote:

> On Jan 15, 2021, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> > On Thu, 14 Jan 2021, 22:22 Alexandre Oliva, <oliva@adacore.com> wrote:
> >> ... it is definitely the case that the target currently defines wchar_t,
> >> and it even offers wchar.h and a lot of (maybe all?) wcs* functions.
> >> This was likely not the case when the patch was first written.
> >>
> >> I'll double check whether any of the patch is still needed for current
> >> versions.
>
> With the tests I've run since yesterday, I've determined that:
>
> - the wchar-related patches for the libstdc++ testsuite, that I had
>   proposed last year, are no longer needed
>
> - your two patchlets did not bring about any regressions to test
>   results, not in mainline x86_64-linux-gnu native, not with the trivial
>   backports to the gcc-10 tree for x-arm-vxw7r2 that was the focus of my
>   immediate attention.
>
> So, I withdraw my submissions of the testsuite patches, and I encourage
> you to proceed with the two changes you proposed.
>

Great, I'll save them in a git branch to be revisited in stage 1.



> However, for avoidance of any doubt, I'll restate that I cannot vow for
> whether they're enough to fix the issues we'd run into back when
> wchar/wcs* were not supported in the target system, because now they
> are, so the changes do not bring any visible improvements to our results
> either.
>

Understood, thanks for checking them though.


>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Add dg-require-wchars to libstdc++ testsuite
  2021-01-15 19:47         ` Jonathan Wakely
@ 2021-10-09  7:31           ` Jonathan Wakely
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2021-10-09  7:31 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: Jonathan Wakely, libstdc++, gcc-patches, Corentin Gay

On Fri, 15 Jan 2021, 19:47 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:

>
>
> On Fri, 15 Jan 2021, 16:19 Alexandre Oliva, <oliva@adacore.com> wrote:
>
>> On Jan 15, 2021, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>
>> > On Thu, 14 Jan 2021, 22:22 Alexandre Oliva, <oliva@adacore.com> wrote:
>> >> ... it is definitely the case that the target currently defines
>> wchar_t,
>> >> and it even offers wchar.h and a lot of (maybe all?) wcs* functions.
>> >> This was likely not the case when the patch was first written.
>> >>
>> >> I'll double check whether any of the patch is still needed for current
>> >> versions.
>>
>> With the tests I've run since yesterday, I've determined that:
>>
>> - the wchar-related patches for the libstdc++ testsuite, that I had
>>   proposed last year, are no longer needed
>>
>> - your two patchlets did not bring about any regressions to test
>>   results, not in mainline x86_64-linux-gnu native, not with the trivial
>>   backports to the gcc-10 tree for x-arm-vxw7r2 that was the focus of my
>>   immediate attention.
>>
>> So, I withdraw my submissions of the testsuite patches, and I encourage
>> you to proceed with the two changes you proposed.
>>
>
> Great, I'll save them in a git branch to be revisited in stage 1.
>

I've committed a series of 8 patches to enable partial wchar_t support even
without a working <wchar.h> in libc. std::wstring and std::wstring_view
should work fine now (albeit slower than if libc provides optimised wcslen
etc.)

Wide character I/O and charset conversions still require libc support, so
are disabled when _GLIBCXX_USE_WCHAR_T is not defined.

I would appreciate confirmation that this hasn't caused any problems for
vxworks (understanding that vxworks does have wide character support in
libc now, as discussed back in January).




>
>
>> However, for avoidance of any doubt, I'll restate that I cannot vow for
>> whether they're enough to fix the issues we'd run into back when
>> wchar/wcs* were not supported in the target system, because now they
>> are, so the changes do not bring any visible improvements to our results
>> either.
>>
>
> Understood, thanks for checking them though.
>
>
>>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-10-09  7:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 21:12 Add dg-require-wchars to libstdc++ testsuite 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
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

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).