summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-01 16:37:20 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-01 16:37:20 +0000
commit7bb5e457e6d4b5a127faae5f180d7c672424fdad (patch)
treeacb5e18efe0ce7f8e02ae5ae9c902a43ad4bcf8d /libstdc++-v3
parentb0bb73953d6ad761e985395103b13e1606a68b28 (diff)
downloadgcc-7bb5e457e6d4b5a127faae5f180d7c672424fdad.tar.gz
2003-02-01 Paolo Carlini <pcarlini@unitus.it>
Benjamin Kosnik <bkoz@redhat.com> Const correctness issue: http://gcc.gnu.org/ml/libstdc++/2003-01/msg00370.html * include/bits/locale_classes.h (locale::_Impl::_M_facets): Change type to const facet**. (locale::_Impl::_M_install_facet): Change declaration to take const facet*. (locale::facet::_M_references): Make mutable. (locale::facet::_M_add_reference): Declare const. (locale::facet::_M_remove_reference): Likewise. * include/bits/locale_facets.tcc (use_facet(const locale&)): Tweak for const facet** _M_facets. (has_facet(const locale&)): Likewise. * src/locale.cc (locale::facet::_M_add_reference): Adjust definition. (locale::facet::_M_remove_reference): Likewise. * src/localename.cc (locale::_Impl::_Impl(const _Impl&, size_t)): Tweak for const facet** _M_facets. (locale::_Impl::_Impl(const char*, size_t)): Likewise. (locale::_Impl::_Impl(facet**, size_t, bool)): Likewise. (locale::_Impl::_M_install_facet): Adjust definition to take const facet* and for const facet** _M_facets. * testsuite/22_locale/locale/cons/8.cc: Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@62248 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog27
-rw-r--r--libstdc++-v3/include/bits/locale_classes.h10
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc4
-rw-r--r--libstdc++-v3/src/locale.cc4
-rw-r--r--libstdc++-v3/src/localename.cc16
-rw-r--r--libstdc++-v3/testsuite/22_locale/locale/cons/8.cc43
6 files changed, 87 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index fd0d93fa2e7..58e008e6838 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,30 @@
+2003-02-01 Paolo Carlini <pcarlini@unitus.it>
+ Benjamin Kosnik <bkoz@redhat.com>
+
+ Const correctness issue:
+ http://gcc.gnu.org/ml/libstdc++/2003-01/msg00370.html
+ * include/bits/locale_classes.h
+ (locale::_Impl::_M_facets): Change type to const facet**.
+ (locale::_Impl::_M_install_facet): Change declaration to
+ take const facet*.
+ (locale::facet::_M_references): Make mutable.
+ (locale::facet::_M_add_reference): Declare const.
+ (locale::facet::_M_remove_reference): Likewise.
+ * include/bits/locale_facets.tcc
+ (use_facet(const locale&)): Tweak for const facet** _M_facets.
+ (has_facet(const locale&)): Likewise.
+ * src/locale.cc
+ (locale::facet::_M_add_reference): Adjust definition.
+ (locale::facet::_M_remove_reference): Likewise.
+ * src/localename.cc
+ (locale::_Impl::_Impl(const _Impl&, size_t)): Tweak for
+ const facet** _M_facets.
+ (locale::_Impl::_Impl(const char*, size_t)): Likewise.
+ (locale::_Impl::_Impl(facet**, size_t, bool)): Likewise.
+ (locale::_Impl::_M_install_facet): Adjust definition to take
+ const facet* and for const facet** _M_facets.
+ * testsuite/22_locale/locale/cons/8.cc: Add.
+
2003-01-29 Mark Mitchell <mark@codesourcery.com>
* include/std/std_limits.h (numeric_limits<float>::has_infinity):
diff --git a/libstdc++-v3/include/bits/locale_classes.h b/libstdc++-v3/include/bits/locale_classes.h
index f36c8d4dea4..5e6d5f1f868 100644
--- a/libstdc++-v3/include/bits/locale_classes.h
+++ b/libstdc++-v3/include/bits/locale_classes.h
@@ -199,7 +199,7 @@ namespace std
private:
// Data Members.
_Atomic_word _M_references;
- facet** _M_facets;
+ const facet** _M_facets;
size_t _M_facets_size;
char* _M_names[_S_categories_size
@@ -260,7 +260,7 @@ namespace std
_M_replace_facet(const _Impl*, const locale::id*);
void
- _M_install_facet(const locale::id*, facet*);
+ _M_install_facet(const locale::id*, const facet*);
template<typename _Facet>
inline void
@@ -291,7 +291,7 @@ namespace std
friend class locale;
friend class locale::_Impl;
- _Atomic_word _M_references;
+ mutable _Atomic_word _M_references;
protected:
// Contains data from the underlying "C" library for the classic locale.
@@ -318,10 +318,10 @@ namespace std
private:
void
- _M_add_reference() throw();
+ _M_add_reference() const throw();
void
- _M_remove_reference() throw();
+ _M_remove_reference() const throw();
facet(const facet&); // Not defined.
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 20c75751c6c..c5263a1ed5a 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -71,7 +71,7 @@ namespace std
use_facet(const locale& __loc)
{
size_t __i = _Facet::id._M_id();
- locale::facet** __facets = __loc._M_impl->_M_facets;
+ const locale::facet** __facets = __loc._M_impl->_M_facets;
if (!(__i < __loc._M_impl->_M_facets_size && __facets[__i]))
__throw_bad_cast();
return static_cast<const _Facet&>(*__facets[__i]);
@@ -82,7 +82,7 @@ namespace std
has_facet(const locale& __loc) throw()
{
size_t __i = _Facet::id._M_id();
- locale::facet** __facets = __loc._M_impl->_M_facets;
+ const locale::facet** __facets = __loc._M_impl->_M_facets;
return (__i < __loc._M_impl->_M_facets_size && __facets[__i]);
}
diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc
index 8246f4a5f47..42972e9de40 100644
--- a/libstdc++-v3/src/locale.cc
+++ b/libstdc++-v3/src/locale.cc
@@ -461,12 +461,12 @@ namespace std
void
locale::facet::
- _M_add_reference() throw()
+ _M_add_reference() const throw()
{ __atomic_add(&_M_references, 1); }
void
locale::facet::
- _M_remove_reference() throw()
+ _M_remove_reference() const throw()
{
if (__exchange_and_add(&_M_references, -1) == 1)
{
diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc
index 8a30b897f07..c9528d00c98 100644
--- a/libstdc++-v3/src/localename.cc
+++ b/libstdc++-v3/src/localename.cc
@@ -94,7 +94,7 @@ namespace std
{
try
{
- _M_facets = new facet*[_M_facets_size];
+ _M_facets = new const facet*[_M_facets_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
_M_facets[__i] = 0;
}
@@ -130,7 +130,7 @@ namespace std
try
{
- _M_facets = new facet*[_M_facets_size];
+ _M_facets = new const facet*[_M_facets_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
_M_facets[__i] = 0;
}
@@ -214,7 +214,7 @@ namespace std
locale::facet::_S_create_c_locale(locale::facet::_S_c_locale,
locale::facet::_S_c_name);
- _M_facets = new(&facet_vec) facet*[_M_facets_size];
+ _M_facets = new(&facet_vec) const facet*[_M_facets_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
_M_facets[__i] = 0;
@@ -310,7 +310,7 @@ namespace std
void
locale::_Impl::
- _M_install_facet(const locale::id* __idp, facet* __fp)
+ _M_install_facet(const locale::id* __idp, const facet* __fp)
{
if (__fp)
{
@@ -319,10 +319,10 @@ namespace std
// Check size of facet vector to ensure adequate room.
if (__index > _M_facets_size - 1)
{
- facet** __old = _M_facets;
- facet** __new;
+ const facet** __old = _M_facets;
+ const facet** __new;
const size_t __new_size = __index + 4;
- __new = new facet*[__new_size];
+ __new = new const facet*[__new_size];
for (size_t __i = 0; __i < _M_facets_size; ++__i)
__new[__i] = _M_facets[__i];
for (size_t __i2 = _M_facets_size; __i2 < __new_size; ++__i2)
@@ -334,7 +334,7 @@ namespace std
}
__fp->_M_add_reference();
- facet*& __fpr = _M_facets[__index];
+ const facet*& __fpr = _M_facets[__index];
if (__fpr)
{
// Replacing an existing facet. Order matters.
diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/8.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/8.cc
new file mode 100644
index 00000000000..433fc1fe9ba
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/8.cc
@@ -0,0 +1,43 @@
+// 2003-02-01 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003 Free Software Foundation
+//
+// 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 2, 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.1.1.2 locale constructors and destructors [lib.locale.cons]
+
+#include <locale>
+
+// Const correctness issue:
+// http://gcc.gnu.org/ml/libstdc++/2003-01/msg00370.html
+void
+test01()
+{
+ using namespace std;
+ bool test = true;
+
+ const locale l1("C");
+ const locale l2 =
+ locale(locale::classic(), &use_facet<time_get<char> >(l1));
+}
+
+
+int main()
+{
+ test01();
+ return 0;
+}