From 451e92db80435a2f60aa2483b29647ba4931d7f4 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Thu, 15 Sep 2005 18:58:02 +0000 Subject: [PATCH] re PR libstdc++/21674 (basic_string vs debug_mode) 2005-09-15 Benjamin Kosnik PR libstdc++/21674 PR libstdc++/22205 PR libstdc++/22222 * include/bits/c++config: Set _GLIBCXX_STD regardless of __GXX_WEAK__. Add in check for __NO_INLINE__ for warning. * testsuite/lib/dg-options.exp (dg-require-debug-mode): New. * testsuite/lib/libstdc++.exp (check_v3_target_debug_mode): New. * testsuite/21_strings/basic_string/element_access/char/21674.cc: Use it. * testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc: Use it. From-SVN: r104314 --- libstdc++-v3/ChangeLog | 14 +++++ libstdc++-v3/include/bits/c++config | 10 ++-- .../basic_string/element_access/char/21674.cc | 1 + .../element_access/wchar_t/21674.cc | 1 + libstdc++-v3/testsuite/lib/dg-options.exp | 9 +++ libstdc++-v3/testsuite/lib/libstdc++.exp | 56 ++++++++++++++++++- 6 files changed, 84 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1d8713e473e..ddb1b38d8d5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,17 @@ +2005-09-15 Benjamin Kosnik + + PR libstdc++/21674 + PR libstdc++/22205 + PR libstdc++/22222 + * include/bits/c++config: Set _GLIBCXX_STD regardless of __GXX_WEAK__. + Add in check for __NO_INLINE__ for warning. + * testsuite/lib/dg-options.exp (dg-require-debug-mode): New. + * testsuite/lib/libstdc++.exp (check_v3_target_debug_mode): New. + * testsuite/21_strings/basic_string/element_access/char/21674.cc: + Use it. + * testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc: + Use it. + 2005-09-15 Paolo Carlini PR libstdc++/23875 diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 96d899546b2..75b7236964d 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -45,10 +45,8 @@ namespace __gnu_debug } #ifdef _GLIBCXX_DEBUG -# if __GXX_WEAK__ -# define _GLIBCXX_STD __gnu_norm -# define _GLIBCXX_EXTERN_TEMPLATE 0 - +# define _GLIBCXX_STD __gnu_norm +# define _GLIBCXX_EXTERN_TEMPLATE 0 namespace __gnu_norm { using namespace std; @@ -57,8 +55,8 @@ namespace std { using namespace __gnu_debug_def __attribute__ ((strong)); } -# else -# warning debug mode disabled due to lack of weak symbol support +# if __NO_INLINE__ && !__GXX_WEAK__ +# warning debug mode without inlining may fail due to lack of weak symbols # endif #else # define _GLIBCXX_STD std diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc index ea06de50837..3f61fa6ce32 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc @@ -1,3 +1,4 @@ +// { dg-require-debug-mode "" } // { dg-options "-O0 -D_GLIBCXX_DEBUG" } // { dg-do run { xfail *-*-* } } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc index bd900687ee1..7c27e2b6a4e 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc @@ -1,3 +1,4 @@ +// { dg-require-debug-mode "" } // { dg-options "-O0 -D_GLIBCXX_DEBUG" } // { dg-do run { xfail *-*-* } } diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 2ab8e425d34..e7bbb41bcd1 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -53,3 +53,12 @@ proc dg-require-sharedlib { args } { } return } + +proc dg-require-debug-mode { args } { + if { ![ check_v3_target_debug_mode ] } { + 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 9c28ba051d5..ba7da26ce21 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -338,7 +338,7 @@ proc v3_target_compile { source dest type options } { # Build the support objects linked in with the libstdc++ tests. In # addition, set v3-wchar_t, v3-threads, v3-test_objs, and v3-symver # appropriately. -proc v3-build_support {} { +proc v3-build_support { } { global srcdir global v3-wchar_t global v3-threads @@ -580,3 +580,57 @@ proc check_v3_target_cxa_atexit { } { } return $et_cxa_atexit } + +proc check_v3_target_debug_mode { } { + global cxxflags + global et_debug_mode + + global tool + + if { ![info exists et_debug_mode_target_name] } { + set et_debug_mode_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_debug_mode_target_name } { + verbose "check_v3_target_debug_mode: `$et_debug_mode_target_name'" 2 + set et_debug_mode_target_name $current_target + if [info exists et_debug_mode] { + verbose "check_v3_target_debug_mode: removing cached result" 2 + unset et_debug_mode + } + } + + if [info exists et_debug_mode] { + verbose "check_v3_target_debug_mode: using cached result" 2 + } else { + set et_debug_mode 0 + + # Set up, compile, and execute a C++ test program that depends + # on correct ordering of static object destructors. This is + # indicative of the presence and use of __cxa_atexit. + set src debug_mode[pid].cc + set exe debug_mode[pid].x + + set f [open $src "w"] + puts $f "#include " + puts $f "using namespace std;" + puts $f "int main()" + puts $f "{ return 0; }" + close $f + + set cxxflags_saved $cxxflags + set cxxflags "$cxxflags -Werror -O0 -D_GLIBCXX_DEBUG" + 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_debug_mode 1 + } + } + verbose "check_v3_target_debug_mode: $et_debug_mode" 2 + return $et_debug_mode +}