diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2008-10-27 15:01:28 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-10-27 15:01:28 +0000 |
commit | 83b83ae97a8d5d291a6209bad3610c686a7138e3 (patch) | |
tree | 1dfe1ecc3ac16dd429c9cf7558681b2482700887 /libstdc++-v3 | |
parent | c3e39a4729808963ecc5426ce563628568c2c4ba (diff) | |
download | gcc-83b83ae97a8d5d291a6209bad3610c686a7138e3.zip gcc-83b83ae97a8d5d291a6209bad3610c686a7138e3.tar.gz gcc-83b83ae97a8d5d291a6209bad3610c686a7138e3.tar.bz2 |
re PR libstdc++/37522 (Incorrect vswprintf prototype breaks __to_xstring)
2008-10-27 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/37522
* config/os/mingw32/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSWPRINTF
* include/bits/basic_string.h: Guard string conversions with
!defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) too.
* testsuite/lib/libstdc++.exp (check_v3_target_string_conversions):
New.
* testsuite/lib/dg-options.exp (dg-require-string-conversions): New.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Use the latter.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
stoull.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/
to_string.cc: Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
Likewise.
From-SVN: r141382
Diffstat (limited to 'libstdc++-v3')
14 files changed, 120 insertions, 38 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 97ce9ef..af59f63 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,31 @@ +2008-10-27 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/37522 + * config/os/mingw32/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSWPRINTF + * include/bits/basic_string.h: Guard string conversions with + !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) too. + * testsuite/lib/libstdc++.exp (check_v3_target_string_conversions): + New. + * testsuite/lib/dg-options.exp (dg-require-string-conversions): New. + * testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc: + Use the latter. + * testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/ + stoull.cc: Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc: + Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/ + to_string.cc: Likewise. + * testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc: + Likewise. + 2008-10-24 Paolo Carlini <paolo.carlini@oracle.com> * config/os/generic/error_constants.h (enum errc): Remove diff --git a/libstdc++-v3/config/os/mingw32/os_defines.h b/libstdc++-v3/config/os/mingw32/os_defines.h index 3ac8fff..017fd87 100644 --- a/libstdc++-v3/config/os/mingw32/os_defines.h +++ b/libstdc++-v3/config/os/mingw32/os_defines.h @@ -1,6 +1,7 @@ // Specific definitions for generic platforms -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -52,4 +53,7 @@ // See libstdc++/20806. #define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1 +// See libstdc++/37522. +#define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1 + #endif diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index de4cf80..595a156 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -2562,7 +2562,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_END_NAMESPACE -#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99)) +#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && defined(_GLIBCXX_USE_C99) \ + && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) #include <ext/string_conversions.h> diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc index 765c5a2..1f6ec0f 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -129,8 +129,6 @@ test01() VERIFY( test ); VERIFY( d1 == -1.0 ); } - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc index 5645c0a..32510e0 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -129,8 +129,6 @@ test01() VERIFY( test ); VERIFY( f1 == -1.0f ); } - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc index 6f1efd0..0dc2df2 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -194,8 +194,6 @@ test01() } VERIFY( test ); VERIFY( i1 == 1 ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc index 683063f..25970f2 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -157,8 +157,6 @@ test01() } VERIFY( test ); VERIFY( l1 == numeric_limits<long>::min() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc index 3a5d73a..54f4ffe 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -106,8 +106,6 @@ test01() test = false; } VERIFY( test ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc index 6d92215..b20c5c5 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -157,8 +157,6 @@ test01() } VERIFY( test ); VERIFY( ll1 == numeric_limits<long long>::min() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc index c2d6cea..20c6e08 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -144,8 +144,6 @@ test01() } VERIFY( test ); VERIFY( ul1 == numeric_limits<unsigned long>::max() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc index 30c94ff..94ef496 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -29,8 +31,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = false; using namespace std; @@ -144,8 +144,6 @@ test01() } VERIFY( test ); VERIFY( ull1 == numeric_limits<unsigned long long>::max() ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc index 7a7d065..a332c41 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc @@ -1,4 +1,6 @@ // { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + // 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com> // Copyright (C) 2008 Free Software Foundation, Inc. @@ -27,8 +29,6 @@ void test01() { -#ifdef _GLIBCXX_USE_C99 - bool test __attribute__((unused)) = true; using namespace std; @@ -55,8 +55,6 @@ test01() long double ld2 = -4.0L; string six(to_string(ld2)); VERIFY( six == "-4.000000" ); - -#endif } int main() diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 0f1bfcf..7807225 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -124,3 +124,12 @@ proc dg-require-nanosleep { args } { } return } + +proc dg-require-string-conversions { args } { + if { ![ check_v3_target_string_conversions ] } { + upvar dg-do-what dg-do-what + set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] + return + } + return +} diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 10eac62..8a4e8c4 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1236,3 +1236,61 @@ proc check_v3_target_nanosleep { } { verbose "check_v3_target_nanosleep: $et_nanosleep" 2 return $et_nanosleep } + +proc check_v3_target_string_conversions { } { + global cxxflags + global DEFAULT_CXXFLAGS + global et_string_conversions + + global tool + + if { ![info exists et_string_conversions_target_name] } { + set et_string_conversions_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_string_conversions_target_name } { + verbose "check_v3_target_string_conversions: `$et_string_conversions_target_name'" 2 + set et_string_conversions_target_name $current_target + if [info exists et_string_conversions] { + verbose "check_v3_target_string_conversions: removing cached result" 2 + unset et_string_conversions + } + } + + if [info exists et_string_conversions] { + verbose "check_v3_target_string_conversions: using cached result" 2 + } else { + set et_string_conversions 0 + + # Set up and compile a C++0x test program that depends + # on the string_conversions facilities to be available. + set src string_conversions[pid].cc + set exe string_conversions[pid].exe + + set f [open $src "w"] + puts $f "#include <bits/c++config.h>" + puts $f "int main()" + puts $f "#if defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)" + puts $f "{ return 0; }" + puts $f "#endif" + close $f + + set cxxflags_saved $cxxflags + set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" + + set lines [v3_target_compile $src $exe executable ""] + set cxxflags $cxxflags_saved + file delete $src + + if [string match "" $lines] { + # No error message, compilation succeeded. + set et_string_conversions 1 + } else { + verbose "check_v3_target_string_conversions: compilation failed" 2 + } + } + verbose "check_v3_target_string_conversions: $et_string_conversions" 2 + return $et_string_conversions +} |