Commit adad2a7d by François Dumont

2015-05-29 François Dumont fdumont@gcc.gnu.org>

	* include/debug/debug.h (_GLIBCXX_DEBUG_ASSERT,
	_GLIBCXX_DEBUG_PEDASSERT, _GLIBCXX_DEBUG_ONLY): Move definition...
	* include/debug/assertions.h: ...here, new.
	* include/debug/formatter.h
	(_Error_formatter::_Is_iterator_value_type): New.
	(_Error_formatter::_Is_instance): New.
	(_Error_formatter::_Parameter): Make public and not friend anymore.
	(_Error_formatter::_Parameter::__instance): New _M_kind enum entry.
	(_Error_formatter::_Parameter::__iterator_value_type): New _M_kind enum
	entry.
	(_Error_formatter::_Parameter::_Type): New.
	(_Error_formatter::_Parameter::_Instance): New, inherit from
	latter.
	(union _Error_formatter::_Parameter::_M_variant): Reorganize.
	(_Parameter(_Iterator const&, const char*, _Is_iterator)): Make all
	overloads take iterator through a const reference.
	(_Parameter(const _Iterator&, const char*, _Is_iterator_value_type)):
	New.
	(_Parameter(const _Type&, const char*, _Is_instance)): New.
	(_Error_formatter::_M_print_type): Delete.
	(_Error_formatter::_M_iterator_value_type): New.
	(_Error_formatter::_M_instance): New.
	* include/Makefile.am: Add new above debug file.
	* include/Makefile.in: Regenerate.
	* include/debug/functions.h
	(__check_dereferenceable(const _Safe_iterator<>&),
	__valid_range(const _Safe_iterator<>&),
	__is_safe_random_iterator<_Safe_iterator<>>): Move...
	* include/debug/safe_iterator.h: ... here.
	Replace debug.h include with assertions.h.
	(__check_singular_aux): Move...
	* include/debug/safe_base.h: ... here.
	* include/debug/functions.h
	(__check_dereferenceable(const _Safe_local_iterator<>&),
	__valid_range(const _Safe_local_iterator<>&): Move...
	* include/debug/safe_local_iterator.h: ...here.
	* include/debug/safe_sequence.h: Replace debug.h with assertions.h.
	Remove _Safe_iterator declaration.
	* include/debug/safe_unordered_container.h: Replace debug.h with
	assertions.h.
	* include/debug/array: Replace safe_sequence.h include with
	formatter.h and macros.h.
	* include/debug/deque: Include functions.tcc.
	* include/debug/forward_list: Likewise.
	* include/debug/list: Likewise.
	* include/debug/string: Likewise.
	* include/debug/vector: Likewise.
	* include/bits/unique_ptr.h: Replace debug.h include with new
	assertions.h.
	* include/bits/stl_iterator_base_funcs.h: Likewise.
	* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/array/tuple_interface/
	tuple_element_debug_neg.cc: Likewise.
	* src/c++11/debug.cc: Adapt.

From-SVN: r223877
parent 8fd0be75
2015-05-29 François Dumont fdumont@gcc.gnu.org>
* include/debug/debug.h (_GLIBCXX_DEBUG_ASSERT,
_GLIBCXX_DEBUG_PEDASSERT, _GLIBCXX_DEBUG_ONLY): Move definition...
* include/debug/assertions.h: ...here, new.
* include/debug/formatter.h
(_Error_formatter::_Is_iterator_value_type): New.
(_Error_formatter::_Is_instance): New.
(_Error_formatter::_Parameter): Make public and not friend anymore.
(_Error_formatter::_Parameter::__instance): New _M_kind enum entry.
(_Error_formatter::_Parameter::__iterator_value_type): New _M_kind enum
entry.
(_Error_formatter::_Parameter::_Type): New.
(_Error_formatter::_Parameter::_Instance): New, inherit from
latter.
(union _Error_formatter::_Parameter::_M_variant): Reorganize.
(_Parameter(_Iterator const&, const char*, _Is_iterator)): Make all
overloads take iterator through a const reference.
(_Parameter(const _Iterator&, const char*, _Is_iterator_value_type)):
New.
(_Parameter(const _Type&, const char*, _Is_instance)): New.
(_Error_formatter::_M_print_type): Delete.
(_Error_formatter::_M_iterator_value_type): New.
(_Error_formatter::_M_instance): New.
* include/Makefile.am: Add new above debug file.
* include/Makefile.in: Regenerate.
* include/debug/functions.h
(__check_dereferenceable(const _Safe_iterator<>&),
__valid_range(const _Safe_iterator<>&),
__is_safe_random_iterator<_Safe_iterator<>>): Move...
* include/debug/safe_iterator.h: ... here.
Replace debug.h include with assertions.h.
(__check_singular_aux): Move...
* include/debug/safe_base.h: ... here.
* include/debug/functions.h
(__check_dereferenceable(const _Safe_local_iterator<>&),
__valid_range(const _Safe_local_iterator<>&): Move...
* include/debug/safe_local_iterator.h: ...here.
* include/debug/safe_sequence.h: Replace debug.h with assertions.h.
Remove _Safe_iterator declaration.
* include/debug/safe_unordered_container.h: Replace debug.h with
assertions.h.
* include/debug/array: Replace safe_sequence.h include with
formatter.h and macros.h.
* include/debug/deque: Include functions.tcc.
* include/debug/forward_list: Likewise.
* include/debug/list: Likewise.
* include/debug/string: Likewise.
* include/debug/vector: Likewise.
* include/bits/unique_ptr.h: Replace debug.h include with new
assertions.h.
* include/bits/stl_iterator_base_funcs.h: Likewise.
* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/array/tuple_interface/
tuple_element_debug_neg.cc: Likewise.
* src/c++11/debug.cc: Adapt.
2015-05-29 Jonathan Wakely <jwakely@redhat.com> 2015-05-29 Jonathan Wakely <jwakely@redhat.com>
* doc/xml/manual/status_cxx2017.xml: Fix duplicate ID attribute. * doc/xml/manual/status_cxx2017.xml: Fix duplicate ID attribute.
......
...@@ -759,6 +759,7 @@ debug_srcdir = ${glibcxx_srcdir}/include/debug ...@@ -759,6 +759,7 @@ debug_srcdir = ${glibcxx_srcdir}/include/debug
debug_builddir = ./debug debug_builddir = ./debug
debug_headers = \ debug_headers = \
${debug_srcdir}/array \ ${debug_srcdir}/array \
${debug_srcdir}/assertions.h \
${debug_srcdir}/bitset \ ${debug_srcdir}/bitset \
${debug_srcdir}/debug.h \ ${debug_srcdir}/debug.h \
${debug_srcdir}/deque \ ${debug_srcdir}/deque \
......
...@@ -1040,6 +1040,7 @@ debug_srcdir = ${glibcxx_srcdir}/include/debug ...@@ -1040,6 +1040,7 @@ debug_srcdir = ${glibcxx_srcdir}/include/debug
debug_builddir = ./debug debug_builddir = ./debug
debug_headers = \ debug_headers = \
${debug_srcdir}/array \ ${debug_srcdir}/array \
${debug_srcdir}/assertions.h \
${debug_srcdir}/bitset \ ${debug_srcdir}/bitset \
${debug_srcdir}/debug.h \ ${debug_srcdir}/debug.h \
${debug_srcdir}/deque \ ${debug_srcdir}/deque \
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
#pragma GCC system_header #pragma GCC system_header
#include <bits/concept_check.h> #include <bits/concept_check.h>
#include <debug/debug.h> #include <debug/assertions.h>
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define _UNIQUE_PTR_H 1 #define _UNIQUE_PTR_H 1
#include <bits/c++config.h> #include <bits/c++config.h>
#include <debug/debug.h> #include <debug/assertions.h>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include <tuple> #include <tuple>
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
#pragma GCC system_header #pragma GCC system_header
#include <debug/safe_sequence.h> #include <debug/formatter.h>
#include <debug/macros.h>
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
......
// Debugging support implementation -*- C++ -*-
// Copyright (C) 2003-2015 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file debug/assertions.h
* This file is a GNU debug extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_DEBUG_ASSERTIONS_H
#define _GLIBCXX_DEBUG_ASSERTIONS_H 1
#ifndef _GLIBCXX_DEBUG
# define _GLIBCXX_DEBUG_ASSERT(_Condition)
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
# define _GLIBCXX_DEBUG_ONLY(_Statement) ;
#else
#define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
#ifdef _GLIBCXX_DEBUG_PEDANTIC
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
#else
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
#endif
# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
#endif
#endif // _GLIBCXX_DEBUG_ASSERTIONS
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
* the standard library algorithms. * the standard library algorithms.
*/ */
#include <debug/assertions.h>
// Debug mode namespaces. // Debug mode namespaces.
/** /**
...@@ -58,9 +60,6 @@ namespace __gnu_debug ...@@ -58,9 +60,6 @@ namespace __gnu_debug
#ifndef _GLIBCXX_DEBUG #ifndef _GLIBCXX_DEBUG
# define _GLIBCXX_DEBUG_ASSERT(_Condition)
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
# define _GLIBCXX_DEBUG_ONLY(_Statement) ;
# define __glibcxx_requires_cond(_Cond,_Msg) # define __glibcxx_requires_cond(_Cond,_Msg)
# define __glibcxx_requires_valid_range(_First,_Last) # define __glibcxx_requires_valid_range(_First,_Last)
# define __glibcxx_requires_non_empty_range(_First,_Last) # define __glibcxx_requires_non_empty_range(_First,_Last)
...@@ -83,16 +82,6 @@ namespace __gnu_debug ...@@ -83,16 +82,6 @@ namespace __gnu_debug
# include <debug/macros.h> # include <debug/macros.h>
#define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
#ifdef _GLIBCXX_DEBUG_PEDANTIC
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
#else
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
#endif
# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
# define __glibcxx_requires_valid_range(_First,_Last) \ # define __glibcxx_requires_valid_range(_First,_Last) \
__glibcxx_check_valid_range(_First,_Last) __glibcxx_check_valid_range(_First,_Last)
......
...@@ -154,8 +154,11 @@ namespace __gnu_debug ...@@ -154,8 +154,11 @@ namespace __gnu_debug
// Tags denoting the type of parameter for construction // Tags denoting the type of parameter for construction
struct _Is_iterator { }; struct _Is_iterator { };
struct _Is_iterator_value_type { };
struct _Is_sequence { }; struct _Is_sequence { };
struct _Is_instance { };
public:
// A parameter that may be referenced by an error message // A parameter that may be referenced by an error message
struct _Parameter struct _Parameter
{ {
...@@ -165,17 +168,27 @@ namespace __gnu_debug ...@@ -165,17 +168,27 @@ namespace __gnu_debug
__iterator, __iterator,
__sequence, __sequence,
__integer, __integer,
__string __string,
__instance,
__iterator_value_type
} _M_kind; } _M_kind;
struct _Type
{
const char* _M_name;
const type_info* _M_type;
};
struct _Instance : _Type
{
const void* _M_address;
};
union union
{ {
// When _M_kind == __iterator // When _M_kind == __iterator
struct struct : _Instance
{ {
const char* _M_name;
const void* _M_address;
const type_info* _M_type;
_Constness _M_constness; _Constness _M_constness;
_Iterator_state _M_state; _Iterator_state _M_state;
const void* _M_sequence; const void* _M_sequence;
...@@ -183,12 +196,7 @@ namespace __gnu_debug ...@@ -183,12 +196,7 @@ namespace __gnu_debug
} _M_iterator; } _M_iterator;
// When _M_kind == __sequence // When _M_kind == __sequence
struct _Instance _M_sequence;
{
const char* _M_name;
const void* _M_address;
const type_info* _M_type;
} _M_sequence;
// When _M_kind == __integer // When _M_kind == __integer
struct struct
...@@ -203,6 +211,12 @@ namespace __gnu_debug ...@@ -203,6 +211,12 @@ namespace __gnu_debug
const char* _M_name; const char* _M_name;
const char* _M_value; const char* _M_value;
} _M_string; } _M_string;
// When _M_kind == __instance
_Instance _M_instance;
// When _M_kind == __iterator_value_type
_Type _M_iterator_value_type;
} _M_variant; } _M_variant;
_Parameter() : _M_kind(__unused_param), _M_variant() { } _Parameter() : _M_kind(__unused_param), _M_variant() { }
...@@ -222,7 +236,7 @@ namespace __gnu_debug ...@@ -222,7 +236,7 @@ namespace __gnu_debug
} }
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
_Parameter(const _Safe_iterator<_Iterator, _Sequence>& __it, _Parameter(_Safe_iterator<_Iterator, _Sequence> const& __it,
const char* __name, _Is_iterator) const char* __name, _Is_iterator)
: _M_kind(__iterator), _M_variant() : _M_kind(__iterator), _M_variant()
{ {
...@@ -252,7 +266,7 @@ namespace __gnu_debug ...@@ -252,7 +266,7 @@ namespace __gnu_debug
} }
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
_Parameter(const _Safe_local_iterator<_Iterator, _Sequence>& __it, _Parameter(_Safe_local_iterator<_Iterator, _Sequence> const& __it,
const char* __name, _Is_iterator) const char* __name, _Is_iterator)
: _M_kind(__iterator), _M_variant() : _M_kind(__iterator), _M_variant()
{ {
...@@ -280,33 +294,33 @@ namespace __gnu_debug ...@@ -280,33 +294,33 @@ namespace __gnu_debug
} }
template<typename _Type> template<typename _Type>
_Parameter(const _Type*& __it, const char* __name, _Is_iterator) _Parameter(const _Type* const& __it, const char* __name, _Is_iterator)
: _M_kind(__iterator), _M_variant() : _M_kind(__iterator), _M_variant()
{ {
_M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_address = &__it;
_M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it);
_M_variant._M_iterator._M_constness = __mutable_iterator; _M_variant._M_iterator._M_constness = __const_iterator;
_M_variant._M_iterator._M_state = __it? __unknown_state : __singular; _M_variant._M_iterator._M_state = __it ? __unknown_state : __singular;
_M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_sequence = 0;
_M_variant._M_iterator._M_seq_type = 0; _M_variant._M_iterator._M_seq_type = 0;
} }
template<typename _Type> template<typename _Type>
_Parameter(_Type*& __it, const char* __name, _Is_iterator) _Parameter(_Type* const& __it, const char* __name, _Is_iterator)
: _M_kind(__iterator), _M_variant() : _M_kind(__iterator), _M_variant()
{ {
_M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_address = &__it;
_M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it);
_M_variant._M_iterator._M_constness = __const_iterator; _M_variant._M_iterator._M_constness = __mutable_iterator;
_M_variant._M_iterator._M_state = __it? __unknown_state : __singular; _M_variant._M_iterator._M_state = __it ? __unknown_state : __singular;
_M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_sequence = 0;
_M_variant._M_iterator._M_seq_type = 0; _M_variant._M_iterator._M_seq_type = 0;
} }
template<typename _Iterator> template<typename _Iterator>
_Parameter(const _Iterator& __it, const char* __name, _Is_iterator) _Parameter(_Iterator const& __it, const char* __name, _Is_iterator)
: _M_kind(__iterator), _M_variant() : _M_kind(__iterator), _M_variant()
{ {
_M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_name = __name;
...@@ -314,7 +328,7 @@ namespace __gnu_debug ...@@ -314,7 +328,7 @@ namespace __gnu_debug
_M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it);
_M_variant._M_iterator._M_constness = __unknown_constness; _M_variant._M_iterator._M_constness = __unknown_constness;
_M_variant._M_iterator._M_state = _M_variant._M_iterator._M_state =
__gnu_debug::__check_singular(__it)? __singular : __unknown_state; __gnu_debug::__check_singular(__it) ? __singular : __unknown_state;
_M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_sequence = 0;
_M_variant._M_iterator._M_seq_type = 0; _M_variant._M_iterator._M_seq_type = 0;
} }
...@@ -339,6 +353,25 @@ namespace __gnu_debug ...@@ -339,6 +353,25 @@ namespace __gnu_debug
_M_variant._M_sequence._M_type = _GLIBCXX_TYPEID(_Sequence); _M_variant._M_sequence._M_type = _GLIBCXX_TYPEID(_Sequence);
} }
template<typename _Iterator>
_Parameter(const _Iterator& __it, const char* __name,
_Is_iterator_value_type)
: _M_kind(__iterator_value_type), _M_variant()
{
_M_variant._M_iterator_value_type._M_name = __name;
_M_variant._M_iterator_value_type._M_type =
_GLIBCXX_TYPEID(typename std::iterator_traits<_Iterator>::value_type);
}
template<typename _Type>
_Parameter(const _Type& __inst, const char* __name, _Is_instance)
: _M_kind(__instance), _M_variant()
{
_M_variant._M_instance._M_name = __name;
_M_variant._M_instance._M_address = &__inst;
_M_variant._M_instance._M_type = _GLIBCXX_TYPEID(_Type);
}
void void
_M_print_field(const _Error_formatter* __formatter, _M_print_field(const _Error_formatter* __formatter,
const char* __name) const; const char* __name) const;
...@@ -347,9 +380,6 @@ namespace __gnu_debug ...@@ -347,9 +380,6 @@ namespace __gnu_debug
_M_print_description(const _Error_formatter* __formatter) const; _M_print_description(const _Error_formatter* __formatter) const;
}; };
friend struct _Parameter;
public:
template<typename _Iterator> template<typename _Iterator>
const _Error_formatter& const _Error_formatter&
_M_iterator(const _Iterator& __it, const char* __name = 0) const _M_iterator(const _Iterator& __it, const char* __name = 0) const
...@@ -360,6 +390,17 @@ namespace __gnu_debug ...@@ -360,6 +390,17 @@ namespace __gnu_debug
return *this; return *this;
} }
template<typename _Iterator>
const _Error_formatter&
_M_iterator_value_type(const _Iterator& __it,
const char* __name = 0) const
{
if (_M_num_parameters < std::size_t(__max_parameters))
_M_parameters[_M_num_parameters++] =
_Parameter(__it, __name, _Is_iterator_value_type());
return *this;
}
const _Error_formatter& const _Error_formatter&
_M_integer(long __value, const char* __name = 0) const _M_integer(long __value, const char* __name = 0) const
{ {
...@@ -386,6 +427,16 @@ namespace __gnu_debug ...@@ -386,6 +427,16 @@ namespace __gnu_debug
return *this; return *this;
} }
template<typename _Type>
const _Error_formatter&
_M_instance(const _Type& __inst, const char* __name = 0) const
{
if (_M_num_parameters < std::size_t(__max_parameters))
_M_parameters[_M_num_parameters++] = _Parameter(__inst, __name,
_Is_instance());
return *this;
}
const _Error_formatter& const _Error_formatter&
_M_message(const char* __text) const _M_message(const char* __text) const
{ _M_text = __text; return *this; } { _M_text = __text; return *this; }
...@@ -396,12 +447,6 @@ namespace __gnu_debug ...@@ -396,12 +447,6 @@ namespace __gnu_debug
_GLIBCXX_NORETURN void _GLIBCXX_NORETURN void
_M_error() const; _M_error() const;
private:
_Error_formatter(const char* __file, std::size_t __line)
: _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0),
_M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false)
{ _M_get_max_length(); }
template<typename _Tp> template<typename _Tp>
void void
_M_format_word(char*, int, const char*, _Tp) const throw (); _M_format_word(char*, int, const char*, _Tp) const throw ();
...@@ -412,9 +457,11 @@ namespace __gnu_debug ...@@ -412,9 +457,11 @@ namespace __gnu_debug
void void
_M_print_string(const char* __string) const; _M_print_string(const char* __string) const;
void private:
_M_print_type(const type_info* __info, _Error_formatter(const char* __file, std::size_t __line)
const char* __unknown_name) const; : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0),
_M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false)
{ _M_get_max_length(); }
void void
_M_get_max_length() const throw (); _M_get_max_length() const throw ();
......
...@@ -30,14 +30,17 @@ ...@@ -30,14 +30,17 @@
#define _GLIBCXX_DEBUG_FUNCTIONS_H 1 #define _GLIBCXX_DEBUG_FUNCTIONS_H 1
#include <bits/c++config.h> #include <bits/c++config.h>
#include <bits/stl_iterator_base_types.h> // for iterator_traits, categories and #include <bits/stl_iterator_base_types.h> // for iterator_traits,
// _Iter_base // categories and _Iter_base
#include <bits/cpp_type_traits.h> // for __is_integer #include <bits/cpp_type_traits.h> // for __is_integer
#include <bits/move.h> // for __addressof and addressof
#include <bits/move.h> // for __addressof
#include <bits/stl_function.h> // for less #include <bits/stl_function.h> // for less
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
# include <type_traits> // for is_lvalue_reference and __and_ # include <type_traits> // for is_lvalue_reference and
// conditional.
#endif #endif
#include <debug/formatter.h> #include <debug/formatter.h>
namespace __gnu_debug namespace __gnu_debug
...@@ -45,9 +48,6 @@ namespace __gnu_debug ...@@ -45,9 +48,6 @@ namespace __gnu_debug
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
class _Safe_iterator; class _Safe_iterator;
template<typename _Iterator, typename _Sequence>
class _Safe_local_iterator;
template<typename _Sequence> template<typename _Sequence>
struct _Insert_range_from_self_is_safe struct _Insert_range_from_self_is_safe
{ enum { __value = 0 }; }; { enum { __value = 0 }; };
...@@ -85,19 +85,6 @@ namespace __gnu_debug ...@@ -85,19 +85,6 @@ namespace __gnu_debug
__check_dereferenceable(const _Tp* __ptr) __check_dereferenceable(const _Tp* __ptr)
{ return __ptr; } { return __ptr; }
/** Safe iterators know if they are dereferenceable. */
template<typename _Iterator, typename _Sequence>
inline bool
__check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x)
{ return __x._M_dereferenceable(); }
/** Safe local iterators know if they are dereferenceable. */
template<typename _Iterator, typename _Sequence>
inline bool
__check_dereferenceable(const _Safe_local_iterator<_Iterator,
_Sequence>& __x)
{ return __x._M_dereferenceable(); }
/** If the distance between two random access iterators is /** If the distance between two random access iterators is
* nonnegative, assume the range is valid. * nonnegative, assume the range is valid.
*/ */
...@@ -150,20 +137,6 @@ namespace __gnu_debug ...@@ -150,20 +137,6 @@ namespace __gnu_debug
return __valid_range_aux(__first, __last, _Integral()); return __valid_range_aux(__first, __last, _Integral());
} }
/** Safe iterators know how to check if they form a valid range. */
template<typename _Iterator, typename _Sequence>
inline bool
__valid_range(const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last)
{ return __first._M_valid_range(__last); }
/** Safe local iterators know how to check if they form a valid range. */
template<typename _Iterator, typename _Sequence>
inline bool
__valid_range(const _Safe_local_iterator<_Iterator, _Sequence>& __first,
const _Safe_local_iterator<_Iterator, _Sequence>& __last)
{ return __first._M_valid_range(__last); }
/* Checks that [first, last) is a valid range, and then returns /* Checks that [first, last) is a valid range, and then returns
* __first. This routine is useful when we can't use a separate * __first. This routine is useful when we can't use a separate
* assertion statement because, e.g., we are in a constructor. * assertion statement because, e.g., we are in a constructor.
...@@ -535,13 +508,6 @@ namespace __gnu_debug ...@@ -535,13 +508,6 @@ namespace __gnu_debug
typedef std::__false_type __type; typedef std::__false_type __type;
}; };
template<typename _Iterator, typename _Sequence>
struct __is_safe_random_iterator<_Safe_iterator<_Iterator, _Sequence> >
: std::__are_same<std::random_access_iterator_tag,
typename std::iterator_traits<_Iterator>::
iterator_category>
{ };
template<typename _Iterator> template<typename _Iterator>
struct _Siter_base struct _Siter_base
: std::_Iter_base<_Iterator, __is_safe_random_iterator<_Iterator>::__value> : std::_Iter_base<_Iterator, __is_safe_random_iterator<_Iterator>::__value>
......
...@@ -159,6 +159,13 @@ namespace __gnu_debug ...@@ -159,6 +159,13 @@ namespace __gnu_debug
} }
}; };
/** Iterators that derive from _Safe_iterator_base can be determined singular
* or non-singular.
**/
inline bool
__check_singular_aux(const _Safe_iterator_base* __x)
{ return __x->_M_singular(); }
/** /**
* @brief Base class that supports tracking of iterators that * @brief Base class that supports tracking of iterators that
* reference a sequence. * reference a sequence.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_H #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_H
#define _GLIBCXX_DEBUG_SAFE_ITERATOR_H 1 #define _GLIBCXX_DEBUG_SAFE_ITERATOR_H 1
#include <debug/debug.h> #include <debug/assertions.h>
#include <debug/macros.h> #include <debug/macros.h>
#include <debug/functions.h> #include <debug/functions.h>
#include <debug/safe_base.h> #include <debug/safe_base.h>
...@@ -55,13 +55,6 @@ namespace __gnu_debug ...@@ -55,13 +55,6 @@ namespace __gnu_debug
{ return __it.base() == __it._M_get_sequence()->_M_base().begin(); } { return __it.base() == __it._M_get_sequence()->_M_base().begin(); }
}; };
/** Iterators that derive from _Safe_iterator_base can be determined singular
* or non-singular.
**/
inline bool
__check_singular_aux(const _Safe_iterator_base* __x)
{ return __x->_M_singular(); }
/** The precision to which we can calculate the distance between /** The precision to which we can calculate the distance between
* two iterators. * two iterators.
*/ */
...@@ -93,11 +86,7 @@ namespace __gnu_debug ...@@ -93,11 +86,7 @@ namespace __gnu_debug
inline std::pair<typename std::iterator_traits<_Iterator>::difference_type, inline std::pair<typename std::iterator_traits<_Iterator>::difference_type,
_Distance_precision> _Distance_precision>
__get_distance(const _Iterator& __lhs, const _Iterator& __rhs) __get_distance(const _Iterator& __lhs, const _Iterator& __rhs)
{ { return __get_distance(__lhs, __rhs, std::__iterator_category(__lhs)); }
typedef typename std::iterator_traits<_Iterator>::iterator_category
_Category;
return __get_distance(__lhs, __rhs, _Category());
}
/** \brief Safe iterator wrapper. /** \brief Safe iterator wrapper.
* *
...@@ -768,6 +757,27 @@ namespace __gnu_debug ...@@ -768,6 +757,27 @@ namespace __gnu_debug
operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n, operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n,
const _Safe_iterator<_Iterator, _Sequence>& __i) _GLIBCXX_NOEXCEPT const _Safe_iterator<_Iterator, _Sequence>& __i) _GLIBCXX_NOEXCEPT
{ return __i + __n; } { return __i + __n; }
/** Safe iterators know if they are dereferenceable. */
template<typename _Iterator, typename _Sequence>
inline bool
__check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x)
{ return __x._M_dereferenceable(); }
/** Safe iterators know how to check if they form a valid range. */
template<typename _Iterator, typename _Sequence>
inline bool
__valid_range(const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last)
{ return __first._M_valid_range(__last); }
template<typename _Iterator, typename _Sequence>
struct __is_safe_random_iterator<_Safe_iterator<_Iterator, _Sequence> >
: std::__are_same<std::random_access_iterator_tag,
typename std::iterator_traits<_Iterator>::
iterator_category>
{ };
} // namespace __gnu_debug } // namespace __gnu_debug
#include <debug/safe_iterator.tcc> #include <debug/safe_iterator.tcc>
......
...@@ -29,11 +29,7 @@ ...@@ -29,11 +29,7 @@
#ifndef _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H #ifndef _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H
#define _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H 1 #define _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H 1
#include <debug/debug.h>
#include <debug/macros.h>
#include <debug/functions.h>
#include <debug/safe_unordered_base.h> #include <debug/safe_unordered_base.h>
#include <ext/type_traits.h>
namespace __gnu_debug namespace __gnu_debug
{ {
...@@ -432,6 +428,20 @@ namespace __gnu_debug ...@@ -432,6 +428,20 @@ namespace __gnu_debug
._M_iterator(__rhs, "rhs")); ._M_iterator(__rhs, "rhs"));
return __lhs.base() != __rhs.base(); return __lhs.base() != __rhs.base();
} }
/** Safe local iterators know if they are dereferenceable. */
template<typename _Iterator, typename _Sequence>
inline bool
__check_dereferenceable(const _Safe_local_iterator<_Iterator,
_Sequence>& __x)
{ return __x._M_dereferenceable(); }
/** Safe local iterators know how to check if they form a valid range. */
template<typename _Iterator, typename _Sequence>
inline bool
__valid_range(const _Safe_local_iterator<_Iterator, _Sequence>& __first,
const _Safe_local_iterator<_Iterator, _Sequence>& __last)
{ return __first._M_valid_range(__last); }
} // namespace __gnu_debug } // namespace __gnu_debug
#include <debug/safe_local_iterator.tcc> #include <debug/safe_local_iterator.tcc>
......
...@@ -29,16 +29,13 @@ ...@@ -29,16 +29,13 @@
#ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H #ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H
#define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1 #define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1
#include <debug/debug.h> #include <debug/assertions.h>
#include <debug/macros.h> #include <debug/macros.h>
#include <debug/functions.h> #include <debug/functions.h>
#include <debug/safe_base.h> #include <debug/safe_base.h>
namespace __gnu_debug namespace __gnu_debug
{ {
template<typename _Iterator, typename _Sequence>
class _Safe_iterator;
/** A simple function object that returns true if the passed-in /** A simple function object that returns true if the passed-in
* value is not equal to the stored value. It saves typing over * value is not equal to the stored value. It saves typing over
* using both bind1st and not_equal. * using both bind1st and not_equal.
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H #ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H
#define _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 1 #define _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 1
#include <debug/debug.h> #include <debug/assertions.h>
#include <debug/macros.h> #include <debug/macros.h>
#include <debug/functions.h> #include <debug/functions.h>
#include <debug/safe_unordered_base.h> #include <debug/safe_unordered_base.h>
......
...@@ -742,8 +742,7 @@ namespace __debug ...@@ -742,8 +742,7 @@ namespace __debug
{ {
size_t size_t
operator()(const __debug::vector<bool, _Alloc>& __b) const noexcept operator()(const __debug::vector<bool, _Alloc>& __b) const noexcept
{ return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>() { return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()(__b); }
(__b._M_base()); }
}; };
#endif #endif
......
...@@ -519,32 +519,135 @@ namespace __gnu_debug ...@@ -519,32 +519,135 @@ namespace __gnu_debug
if (_M_local_iterators == __it) if (_M_local_iterators == __it)
_M_local_iterators = __it->_M_next; _M_local_iterators = __it->_M_next;
} }
}
namespace
{
void void
_Error_formatter::_Parameter:: print_type(const __gnu_debug::_Error_formatter* __formatter,
_M_print_field(const _Error_formatter* __formatter, const char* __name) const const type_info* __info,
const char* __unknown_name)
{ {
assert(this->_M_kind != _Parameter::__unused_param); if (!__info)
const int __bufsize = 64; __formatter->_M_print_word(__unknown_name);
char __buf[__bufsize]; else
{
int __status;
char* __demangled_name =
__cxxabiv1::__cxa_demangle(__info->name(), NULL, NULL, &__status);
__formatter->_M_print_word(__status == 0
? __demangled_name : __info->name());
free(__demangled_name);
}
}
switch (_M_kind) bool
print_field(
const __gnu_debug::_Error_formatter* __formatter,
const char* __name,
const __gnu_debug::_Error_formatter::_Parameter::_Type& __variant)
{ {
case __iterator:
if (strcmp(__name, "name") == 0) if (strcmp(__name, "name") == 0)
{ {
assert(_M_variant._M_iterator._M_name); assert(__variant._M_name);
__formatter->_M_print_word(_M_variant._M_iterator._M_name); __formatter->_M_print_word(__variant._M_name);
}
else if (strcmp(__name, "type") == 0)
print_type(__formatter, __variant._M_type, "<unknown type>");
else
return false;
return true;
} }
bool
print_field(
const __gnu_debug::_Error_formatter* __formatter,
const char* __name,
const __gnu_debug::_Error_formatter::_Parameter::_Instance& __variant)
{
const __gnu_debug::_Error_formatter::_Parameter::_Type& __type = __variant;
if (print_field(__formatter, __name, __type))
{ }
else if (strcmp(__name, "address") == 0) else if (strcmp(__name, "address") == 0)
{ {
const int __bufsize = 64;
char __buf[__bufsize];
__formatter->_M_format_word(__buf, __bufsize, "%p", __formatter->_M_format_word(__buf, __bufsize, "%p",
_M_variant._M_iterator._M_address); __variant._M_address);
__formatter->_M_print_word(__buf); __formatter->_M_print_word(__buf);
} }
else if (strcmp(__name, "type") == 0) else
__formatter->_M_print_type(_M_variant._M_iterator._M_type, return false;
"<unknown type>");
return true;
}
void
print_description(
const __gnu_debug::_Error_formatter* __formatter,
const __gnu_debug::_Error_formatter::_Parameter::_Type& __variant)
{
if (__variant._M_name)
{
const int __bufsize = 64;
char __buf[__bufsize];
__formatter->_M_format_word(__buf, __bufsize, "\"%s\" ",
__variant._M_name);
__formatter->_M_print_word(__buf);
}
if (__variant._M_type)
{
__formatter->_M_print_word(" type = ");
print_type(__formatter, __variant._M_type, "<unknown type>");
__formatter->_M_print_word(";\n");
}
}
void
print_description(
const __gnu_debug::_Error_formatter* __formatter,
const __gnu_debug::_Error_formatter::_Parameter::_Instance& __variant)
{
const int __bufsize = 64;
char __buf[__bufsize];
if (__variant._M_name)
{
__formatter->_M_format_word(__buf, __bufsize, "\"%s\" ",
__variant._M_name);
__formatter->_M_print_word(__buf);
}
__formatter->_M_format_word(__buf, __bufsize, "@ 0x%p {\n",
__variant._M_address);
__formatter->_M_print_word(__buf);
if (__variant._M_type)
{
__formatter->_M_print_word(" type = ");
print_type(__formatter, __variant._M_type, "<unknown type>");
}
}
}
namespace __gnu_debug
{
void
_Error_formatter::_Parameter::
_M_print_field(const _Error_formatter* __formatter, const char* __name) const
{
assert(this->_M_kind != _Parameter::__unused_param);
const int __bufsize = 64;
char __buf[__bufsize];
switch (_M_kind)
{
case __iterator:
if (print_field(__formatter, __name, _M_variant._M_iterator))
{ }
else if (strcmp(__name, "constness") == 0) else if (strcmp(__name, "constness") == 0)
{ {
static const char* __constness_names[__last_constness] = static const char* __constness_names[__last_constness] =
...@@ -579,28 +682,13 @@ namespace __gnu_debug ...@@ -579,28 +682,13 @@ namespace __gnu_debug
__formatter->_M_print_word(__buf); __formatter->_M_print_word(__buf);
} }
else if (strcmp(__name, "seq_type") == 0) else if (strcmp(__name, "seq_type") == 0)
__formatter->_M_print_type(_M_variant._M_iterator._M_seq_type, print_type(__formatter, _M_variant._M_iterator._M_seq_type,
"<unknown seq_type>"); "<unknown seq_type>");
else else
assert(false); assert(false);
break; break;
case __sequence: case __sequence:
if (strcmp(__name, "name") == 0) if (!print_field(__formatter, __name, _M_variant._M_sequence))
{
assert(_M_variant._M_sequence._M_name);
__formatter->_M_print_word(_M_variant._M_sequence._M_name);
}
else if (strcmp(__name, "address") == 0)
{
assert(_M_variant._M_sequence._M_address);
__formatter->_M_format_word(__buf, __bufsize, "%p",
_M_variant._M_sequence._M_address);
__formatter->_M_print_word(__buf);
}
else if (strcmp(__name, "type") == 0)
__formatter->_M_print_type(_M_variant._M_sequence._M_type,
"<unknown type>");
else
assert(false); assert(false);
break; break;
case __integer: case __integer:
...@@ -621,6 +709,14 @@ namespace __gnu_debug ...@@ -621,6 +709,14 @@ namespace __gnu_debug
else else
assert(false); assert(false);
break; break;
case __instance:
if (!print_field(__formatter, __name, _M_variant._M_instance))
assert(false);
break;
case __iterator_value_type:
if (!print_field(__formatter, __name, _M_variant._M_iterator_value_type))
assert(false);
break;
default: default:
assert(false); assert(false);
break; break;
...@@ -638,21 +734,10 @@ namespace __gnu_debug ...@@ -638,21 +734,10 @@ namespace __gnu_debug
{ {
case __iterator: case __iterator:
__formatter->_M_print_word("iterator "); __formatter->_M_print_word("iterator ");
if (_M_variant._M_iterator._M_name) print_description(__formatter, _M_variant._M_iterator);
{
__formatter->_M_format_word(__buf, __bufsize, "\"%s\" ",
_M_variant._M_iterator._M_name);
__formatter->_M_print_word(__buf);
}
__formatter->_M_format_word(__buf, __bufsize, "@ 0x%p {\n",
_M_variant._M_iterator._M_address);
__formatter->_M_print_word(__buf);
if (_M_variant._M_iterator._M_type) if (_M_variant._M_iterator._M_type)
{ {
__formatter->_M_print_word("type = ");
_M_print_field(__formatter, "type");
if (_M_variant._M_iterator._M_constness != __unknown_constness) if (_M_variant._M_iterator._M_constness != __unknown_constness)
{ {
__formatter->_M_print_word(" ("); __formatter->_M_print_word(" (");
...@@ -687,25 +772,25 @@ namespace __gnu_debug ...@@ -687,25 +772,25 @@ namespace __gnu_debug
break; break;
case __sequence: case __sequence:
__formatter->_M_print_word("sequence "); __formatter->_M_print_word("sequence ");
if (_M_variant._M_sequence._M_name) print_description(__formatter, _M_variant._M_sequence);
{
__formatter->_M_format_word(__buf, __bufsize, "\"%s\" ",
_M_variant._M_sequence._M_name);
__formatter->_M_print_word(__buf);
}
__formatter->_M_format_word(__buf, __bufsize, "@ 0x%p {\n",
_M_variant._M_sequence._M_address);
__formatter->_M_print_word(__buf);
if (_M_variant._M_sequence._M_type) if (_M_variant._M_sequence._M_type)
{
__formatter->_M_print_word(" type = ");
_M_print_field(__formatter, "type");
__formatter->_M_print_word(";\n"); __formatter->_M_print_word(";\n");
}
__formatter->_M_print_word("}\n"); __formatter->_M_print_word("}\n");
break; break;
case __instance:
__formatter->_M_print_word("instance ");
print_description(__formatter, _M_variant._M_instance);
if (_M_variant._M_instance._M_type)
__formatter->_M_print_word(";\n");
break;
case __iterator_value_type:
__formatter->_M_print_word("iterator::value_type ");
print_description(__formatter, _M_variant._M_iterator_value_type);
break;
default: default:
break; break;
} }
...@@ -756,6 +841,8 @@ namespace __gnu_debug ...@@ -756,6 +841,8 @@ namespace __gnu_debug
{ {
case _Parameter::__iterator: case _Parameter::__iterator:
case _Parameter::__sequence: case _Parameter::__sequence:
case _Parameter::__instance:
case _Parameter::__iterator_value_type:
if (!__has_noninteger_parameters) if (!__has_noninteger_parameters)
{ {
_M_first_line = true; _M_first_line = true;
...@@ -879,9 +966,9 @@ namespace __gnu_debug ...@@ -879,9 +966,9 @@ namespace __gnu_debug
// Get the parameter number // Get the parameter number
assert(*__start >= '1' && *__start <= '9'); assert(*__start >= '1' && *__start <= '9');
size_t __param = *__start - '0'; size_t __param_index = *__start - '0' - 1;
--__param; assert(__param_index < _M_num_parameters);
assert(__param < _M_num_parameters); const auto& __param = _M_parameters[__param_index];
// '.' separates the parameter number from the field // '.' separates the parameter number from the field
// name, if there is one. // name, if there is one.
...@@ -891,14 +978,14 @@ namespace __gnu_debug ...@@ -891,14 +978,14 @@ namespace __gnu_debug
assert(*__start == ';'); assert(*__start == ';');
++__start; ++__start;
__buf[0] = '\0'; __buf[0] = '\0';
if (_M_parameters[__param]._M_kind == _Parameter::__integer) if (__param._M_kind == _Parameter::__integer)
{ {
_M_format_word(__buf, __bufsize, "%ld", _M_format_word(__buf, __bufsize, "%ld",
_M_parameters[__param]._M_variant._M_integer._M_value); __param._M_variant._M_integer._M_value);
_M_print_word(__buf); _M_print_word(__buf);
} }
else if (_M_parameters[__param]._M_kind == _Parameter::__string) else if (__param._M_kind == _Parameter::__string)
_M_print_string(_M_parameters[__param]._M_variant._M_string._M_value); _M_print_string(__param._M_variant._M_string._M_value);
continue; continue;
} }
...@@ -916,23 +1003,7 @@ namespace __gnu_debug ...@@ -916,23 +1003,7 @@ namespace __gnu_debug
++__start; ++__start;
__field[__field_idx] = 0; __field[__field_idx] = 0;
_M_parameters[__param]._M_print_field(this, __field); __param._M_print_field(this, __field);
}
}
void
_Error_formatter::_M_print_type(const type_info* __info,
const char* __unknown_name) const
{
if (!__info)
_M_print_word(__unknown_name);
else
{
int __status;
char* __demangled_name =
__cxxabiv1::__cxa_demangle(__info->name(), NULL, NULL, &__status);
_M_print_word(__status == 0 ? __demangled_name : __info->name());
free(__demangled_name);
} }
} }
......
...@@ -28,6 +28,6 @@ int n1 = std::get<1>(a); ...@@ -28,6 +28,6 @@ int n1 = std::get<1>(a);
int n2 = std::get<1>(std::move(a)); int n2 = std::get<1>(std::move(a));
int n3 = std::get<1>(ca); int n3 = std::get<1>(ca);
// { dg-error "static assertion failed" "" { target *-*-* } 271 } // { dg-error "static assertion failed" "" { target *-*-* } 272 }
// { dg-error "static assertion failed" "" { target *-*-* } 280 } // { dg-error "static assertion failed" "" { target *-*-* } 281 }
// { dg-error "static assertion failed" "" { target *-*-* } 288 } // { dg-error "static assertion failed" "" { target *-*-* } 289 }
...@@ -23,4 +23,4 @@ ...@@ -23,4 +23,4 @@
typedef std::tuple_element<1, std::array<int, 1>>::type type; typedef std::tuple_element<1, std::array<int, 1>>::type type;
// { dg-error "static assertion failed" "" { target *-*-* } 305 } // { dg-error "static assertion failed" "" { target *-*-* } 306 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment