[_GLIBCXX_ASSERTIONS] Activate __glibcxx_requires_string/__glibcxx_requires_string_len
Commit Message
Following my remark about tests XFAIL-ing when running 'make check' I'd
like to propose this to avoid this situation.
libstdc++: [_GLIBCXX_ASSERTIONS] Activate basic
_GLIBCXX_DEBUB_PEDANTIC checks
Activate __glibcxx_requires_string/__glibcxx_requires_string_len in
basic _GLIBCXX_ASSERTIONS
mode which is then considering _GLIBCXX_DEBUG_PEDANTIC for this
purpose.
Thanks to this change add _GLIBCXX_ASSERTIONS to some tests that
are otherwise XFAIL-ing on
segmentation fault rather than on a proper __glibcxx_assert call.
libstdc++-v3/ChangeLog:
* include/debug/debug.h (__glibcxx_requires_string,
__glibcxx_requires_string_len): Move
definitions...
* include/debug/assertions.h: ... here. Definition now
depends on _GLIBCXX_ASSERTIONS rather
than _GLIBCXX_DEBUG.
*
testsuite/21_strings/basic_string/operations/ends_with/char_neg.cc: Add
_GLIBCXX_ASSERTIONS
define.
*
testsuite/21_strings/basic_string/operations/ends_with/wchar_t_neg.cc:
Likewise.
*
testsuite/21_strings/basic_string/operations/starts_with/char_neg.cc:
Likewise.
*
testsuite/21_strings/basic_string/operations/starts_with/wchar_t_neg.cc:
Likewise.
Tested under Linux x86_64.
Ok to commit ?
François
@@ -43,6 +43,8 @@
# define __glibcxx_requires_non_empty_range(_First,_Last)
# define __glibcxx_requires_nonempty()
# define __glibcxx_requires_subscript(_N)
+# define __glibcxx_requires_string(_String)
+# define __glibcxx_requires_string_len(_String,_Len)
#else
// Verify that [_First, _Last) forms a non-empty iterator range.
@@ -53,6 +55,22 @@
// Verify that the container is nonempty
# define __glibcxx_requires_nonempty() \
__glibcxx_assert(!this->empty())
+# ifdef _GLIBCXX_DEBUG_PEDANTIC
+# if __cplusplus < 201103L
+# define __glibcxx_requires_string(_String) \
+ __glibcxx_assert(_String != 0)
+# define __glibcxx_requires_string_len(_String,_Len) \
+ __glibcxx_assert(_String != 0 || _Len == 0)
+# else
+# define __glibcxx_requires_string(_String) \
+ __glibcxx_assert(_String != nullptr)
+# define __glibcxx_requires_string_len(_String,_Len) \
+ __glibcxx_assert(_String != nullptr || _Len == 0)
+# endif // C++11
+# else
+# define __glibcxx_requires_string(_String)
+# define __glibcxx_requires_string_len(_String,_Len)
+# endif // _GLIBCXX_DEBUG_PEDANTIC
#endif
#ifdef _GLIBCXX_DEBUG
@@ -78,8 +78,6 @@ namespace __gnu_debug
# define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
# define __glibcxx_requires_heap(_First,_Last)
# define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
-# define __glibcxx_requires_string(_String)
-# define __glibcxx_requires_string_len(_String,_Len)
# define __glibcxx_requires_irreflexive(_First,_Last)
# define __glibcxx_requires_irreflexive2(_First,_Last)
# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred)
@@ -118,17 +116,6 @@ namespace __gnu_debug
__glibcxx_check_heap(_First,_Last)
# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
__glibcxx_check_heap_pred(_First,_Last,_Pred)
-# if __cplusplus < 201103L
-# define __glibcxx_requires_string(_String) \
- _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
-# define __glibcxx_requires_string_len(_String,_Len) \
- _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
-# else
-# define __glibcxx_requires_string(_String) \
- _GLIBCXX_DEBUG_PEDASSERT(_String != nullptr)
-# define __glibcxx_requires_string_len(_String,_Len) \
- _GLIBCXX_DEBUG_PEDASSERT(_String != nullptr || _Len == 0)
-# endif
# define __glibcxx_requires_irreflexive(_First,_Last) \
__glibcxx_check_irreflexive(_First,_Last)
# define __glibcxx_requires_irreflexive2(_First,_Last) \
@@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
// { dg-do run { target c++2a xfail *-*-* } }
#define _GLIBCXX_DEBUG_PEDANTIC
@@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
// { dg-do run { target c++2a xfail *-*-* } }
#define _GLIBCXX_DEBUG_PEDANTIC
@@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
// { dg-do run { target c++2a xfail *-*-* } }
#define _GLIBCXX_DEBUG_PEDANTIC
@@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
-// { dg-options "-std=gnu++2a -O0" }
+// { dg-options "-std=gnu++2a -D_GLIBCXX_ASSERTIONS" }
// { dg-do run { target c++2a xfail *-*-* } }
#define _GLIBCXX_DEBUG_PEDANTIC