]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/52562 ([C++11] Most type_info functions not noexcept)
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 12 Mar 2012 15:12:40 +0000 (15:12 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 12 Mar 2012 15:12:40 +0000 (15:12 +0000)
2012-03-12  Paolo Carlini  <paolo.carlini@oracle.com>

PR libstdc++/52562
* libsupc++/typeinfo (type_info::name, before, operator==,
operator!=): Mark noexcept in C++11 mode.
* libsupc++/tinfo.cc (type_info::operator==): Adjust.
* libsupc++/tinfo2.cc (type_info::before): Likewise.
* testsuite/18_support/type_info/52562.cc: New.

From-SVN: r185235

libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/tinfo.cc
libstdc++-v3/libsupc++/tinfo2.cc
libstdc++-v3/libsupc++/typeinfo
libstdc++-v3/testsuite/18_support/type_info/52562.cc [new file with mode: 0644]

index 07bb4fec152415f28f2dca657f666e7a6fe945ff..78d23a5a9fe8a5200f8bea4010d77d61eecb432a 100644 (file)
@@ -1,3 +1,12 @@
+2012-03-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/52562
+       * libsupc++/typeinfo (type_info::name, before, operator==,
+       operator!=): Mark noexcept in C++11 mode.
+       * libsupc++/tinfo.cc (type_info::operator==): Adjust.
+       * libsupc++/tinfo2.cc (type_info::before): Likewise.
+       * testsuite/18_support/type_info/52562.cc: New.
+
 2012-03-10  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * config/abi/post/hppa-linux-gnu/baseline_symbols.txt: Remove TLS
index eba74dbdada5d8530fc8146adfd2420bb8461485..d7affedfc2759f7d9268f92386156102be36d391 100644 (file)
@@ -1,6 +1,6 @@
 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
 // Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-// 2003, 2004, 2005, 2006, 2007, 2009
+// 2003, 2004, 2005, 2006, 2007, 2009, 2012
 // Free Software Foundation
 //
 // This file is part of GCC.
@@ -36,7 +36,7 @@ std::type_info::
 
 // We can't rely on common symbols being shared between shared objects.
 bool std::type_info::
-operator== (const std::type_info& arg) const
+operator== (const std::type_info& arg) const _GLIBCXX_NOEXCEPT
 {
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () == arg.name ();
index 0182c6cc0deb57dd777e1bd5c03838d4ef90ff9d..e4c36649f342806f933f2703748113dab8e64d41 100644 (file)
@@ -1,6 +1,7 @@
 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
 
-// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2009
+// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2009,
+// 2012
 // Free Software Foundation
 //
 // This file is part of GCC.
@@ -32,7 +33,7 @@ using std::type_info;
 #if !__GXX_TYPEINFO_EQUALITY_INLINE
 
 bool
-type_info::before (const type_info &arg) const
+type_info::before (const type_info &arg) const _GLIBCXX_NOEXCEPT
 {
 #if __GXX_MERGED_TYPEINFO_NAMES
   return name () < arg.name ();
index f0382d64f7653c28d355b729b122f29899054974..bf0935cfb5972bf0e0850f02eda48db42c3a4b2f 100644 (file)
@@ -98,15 +98,15 @@ namespace std
 
     /** Returns an @e implementation-defined byte string; this is not
      *  portable between compilers!  */
-    const char* name() const
+    const char* name() const _GLIBCXX_NOEXCEPT
     { return __name[0] == '*' ? __name + 1 : __name; }
 
 #if !__GXX_TYPEINFO_EQUALITY_INLINE
     // In old abi, or when weak symbols are not supported, there can
     // be multiple instances of a type_info object for one
     // type. Uniqueness must use the _name value, not object address.
-    bool before(const type_info& __arg) const;
-    bool operator==(const type_info& __arg) const;
+    bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT;
+    bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT;
 #else
   #if !__GXX_MERGED_TYPEINFO_NAMES
     /** Returns true if @c *this precedes @c __arg in the implementation's
@@ -114,12 +114,12 @@ namespace std
     // Even with the new abi, on systems that support dlopen
     // we can run into cases where type_info names aren't merged,
     // so we still need to do string comparison.
-    bool before(const type_info& __arg) const
+    bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT
     { return (__name[0] == '*' && __arg.__name[0] == '*')
        ? __name < __arg.__name
        : __builtin_strcmp (__name, __arg.__name) < 0; }
 
-    bool operator==(const type_info& __arg) const
+    bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT
     {
       return ((__name == __arg.__name)
              || (__name[0] != '*' &&
@@ -128,14 +128,14 @@ namespace std
   #else
     // On some targets we can rely on type_info's NTBS being unique,
     // and therefore address comparisons are sufficient.
-    bool before(const type_info& __arg) const
+    bool before(const type_info& __arg) const _GLIBCXX_NOEXCEPT
     { return __name < __arg.__name; }
 
-    bool operator==(const type_info& __arg) const
+    bool operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT
     { return __name == __arg.__name; }
   #endif
 #endif
-    bool operator!=(const type_info& __arg) const
+    bool operator!=(const type_info& __arg) const _GLIBCXX_NOEXCEPT
     { return !operator==(__arg); }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
diff --git a/libstdc++-v3/testsuite/18_support/type_info/52562.cc b/libstdc++-v3/testsuite/18_support/type_info/52562.cc
new file mode 100644 (file)
index 0000000..6b2aaf7
--- /dev/null
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2012 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 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <typeinfo>
+
+template<class T> T& lval() noexcept;
+
+// libstdc++/52562
+static_assert(noexcept(lval<std::type_info>().name()), "");
+static_assert(noexcept(lval<std::type_info>().before(lval<std::type_info>())),
+"");
+static_assert(noexcept(lval<std::type_info>() == lval<std::type_info>()), "");
+static_assert(noexcept(lval<std::type_info>() != lval<std::type_info>()), "");