[gcc r16-537] libstdc++: Make dg-require-namedlocale work for more targets [PR65909]

Jonathan Wakely redi@gcc.gnu.org
Mon May 12 08:44:04 GMT 2025


https://gcc.gnu.org/g:3e2b83faeb6b14254641933525e63171e89d973f

commit r16-537-g3e2b83faeb6b14254641933525e63171e89d973f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu May 8 09:57:28 2025 +0100

    libstdc++: Make dg-require-namedlocale work for more targets [PR65909]
    
    As noted in the PR, some embedded targets do not support command-line
    arguments, which means that the dg-require-namedlocale check always
    fails. Use Sandra's suggestion of hardcoding the argument into the
    executable instead of passing it as a command-line argument.
    
    Realistically, those embedded targets probably don't support the named
    locales anyway, but at least now the tests will be UNSUPPORTED for the
    right reason.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/65909
            * testsuite/lib/libstdc++.exp (check_v3_target_namedlocale):
            Hardcode the locale name instead of passing it to the
            executable. Do not hardcode buffer size for string.
    
    Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 5e958d159de2..fbc9f7f13e64 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1034,7 +1034,7 @@ proc check_v3_target_namedlocale { args } {
 	puts $f "using namespace std;"
 	puts $f "char *transform_locale(const char *name)"
 	puts $f "{"
-	puts $f "    char *result = new char\[50\];"
+	puts $f "    char *result = new char\[strlen(name)+6\];"
 	puts $f "    strcpy(result, name);"
 	puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__"
 	puts $f "    /* fall-through */"
@@ -1045,14 +1045,9 @@ proc check_v3_target_namedlocale { args } {
 	puts $f "#endif"
 	puts $f "    return result;"
 	puts $f "}"
-	puts $f "int main (int argc, char** argv)"
+	puts $f "int main ()"
 	puts $f "{"
-	puts $f "  if (argc < 2)"
-	puts $f "  {"
-	puts $f "    printf(\"locale support test not supported\\n\");"
-	puts $f "    return 1;"
-	puts $f "  }"
-	puts $f "  const char *namedloc = transform_locale(*(argv + 1));"
+	puts $f "  const char *namedloc = transform_locale(\"$args\");"
 	puts $f "  try"
 	puts $f "  {"
 	puts $f "    locale((const char*)namedloc);"
@@ -1076,7 +1071,7 @@ proc check_v3_target_namedlocale { args } {
 	  return 0
 	}
 
-	set result [${tool}_load "./$exe" "$args" ""]
+	set result [${tool}_load "./$exe" "" ""]
 	set status [lindex $result 0]
 
 	verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2


More information about the Libstdc++-cvs mailing list