]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make dg-require-namedlocale work for more targets [PR65909]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 8 May 2025 08:57:28 +0000 (09:57 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 12 May 2025 08:42:04 +0000 (09:42 +0100)
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>
libstdc++-v3/testsuite/lib/libstdc++.exp

index 5e958d159de20b7249b488783a8ebb3b12608078..fbc9f7f13e6451f20c39aae248f9672ee052ff4e 100644 (file)
@@ -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