This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] c++/65046 Use abi-tag to fix building with -Werror=abi-tag


This adds the abi_tag attribute in a few places it's missing, so that
-Werror=abi-tag builds will work after Jason's upcoming patches to
make functions inherit the tag from their return type.

For the __sso_string type I disable the warning, because the fact it
uses std::__cxx11::string internally is not visible to users.

There are still some missing tags in the Debug Mode string and list
which I'll fix asap.

Preparing this patch reminded me that we currently have two copies of
the Catalog_info and Catalogs code in the unnamed namespace in
config/locale/gnu/messages_members.cc, one using the old string and
one using the new. We should really alter the code to not use
std::string so that the catalogs can be shared by both versions of the
messages facets.

Tested x86_64-linux, as a standard build, and also with Jason's WIP
patches and --enable-cxx-flags=-Werror=abi-tag.

Committed to trunk.

commit b6a949d6488a8ee72f182e7d859c830b45bf71a0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Mar 17 16:45:32 2015 +0000

    	PR c++/65046
    	* config/locale/gnu/messages_members.cc (Catalog_info, Catalogs,
    	get_catalogs): Add abi-tag.
    	* include/ext/codecvt_specializations.h (encoding_state,
    	encoding_char_traits): Likewise.
    	* src/c++11/cxx11-ios_failure.cc (io_error_category): Likewise.
    	* src/c++11/cxx11-shim_facets.cc (__any_string::operator basic_string,
    	numpunct_shim, collate_shim, time_get_shim, moneypunct_shim,
    	money_get_shim, money_put_shim, messages_shim): Likewise.
    	* src/c++11/future.cc (future_error_category::message): Likewise.
    	* src/c++11/system_error.cc (generic_error_category::message,
    	system_error_category::message): Likewise.
    	(__sso_string): Disable -Wabi-tag warnings.

diff --git a/libstdc++-v3/config/locale/gnu/messages_members.cc b/libstdc++-v3/config/locale/gnu/messages_members.cc
index 2e6122d..c90499e 100644
--- a/libstdc++-v3/config/locale/gnu/messages_members.cc
+++ b/libstdc++-v3/config/locale/gnu/messages_members.cc
@@ -46,8 +46,8 @@ namespace
 
   typedef messages_base::catalog catalog;
 
-  struct Catalog_info
-    {
+  struct _GLIBCXX_DEFAULT_ABI_TAG Catalog_info
+  {
     Catalog_info(catalog __id, const string& __domain, locale __loc)
       : _M_id(__id), _M_domain(__domain), _M_locale(__loc)
     { }
@@ -57,7 +57,7 @@ namespace
     locale _M_locale;
   };
 
-  class Catalogs
+  class _GLIBCXX_DEFAULT_ABI_TAG Catalogs
   {
   public:
     Catalogs() : _M_catalog_counter(0) { }
@@ -133,6 +133,7 @@ namespace
     std::vector<Catalog_info*> _M_infos;
   };
 
+  _GLIBCXX_DEFAULT_ABI_TAG
   Catalogs&
   get_catalogs()
   {
diff --git a/libstdc++-v3/include/ext/codecvt_specializations.h b/libstdc++-v3/include/ext/codecvt_specializations.h
index a24adfc..d9f6630 100644
--- a/libstdc++-v3/include/ext/codecvt_specializations.h
+++ b/libstdc++-v3/include/ext/codecvt_specializations.h
@@ -47,7 +47,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // This includes conversions and comparisons between various character
   // sets.  This object encapsulates data that may need to be shared between
   // char_traits, codecvt and ctype.
-  class encoding_state
+  class _GLIBCXX_DEFAULT_ABI_TAG encoding_state
   {
   public:
     // Types: 
@@ -207,7 +207,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // associated fpos<encoding_state> for the position type, all other
   // bits equivalent to the required char_traits instantiations.
   template<typename _CharT>
-    struct encoding_char_traits : public std::char_traits<_CharT>
+    struct _GLIBCXX_DEFAULT_ABI_TAG encoding_char_traits
+    : public std::char_traits<_CharT>
     {
       typedef encoding_state				state_type;
       typedef typename std::fpos<state_type>		pos_type;
diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
index e1c8d4e..b0a7c46 100644
--- a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
+++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
@@ -41,6 +41,7 @@ namespace
     name() const noexcept
     { return "iostream"; }
 
+    _GLIBCXX_DEFAULT_ABI_TAG
     virtual std::string message(int __ec) const
     {
       std::string __msg;
diff --git a/libstdc++-v3/src/c++11/cxx11-shim_facets.cc b/libstdc++-v3/src/c++11/cxx11-shim_facets.cc
index 82bdf6f..a32b9f0 100644
--- a/libstdc++-v3/src/c++11/cxx11-shim_facets.cc
+++ b/libstdc++-v3/src/c++11/cxx11-shim_facets.cc
@@ -147,6 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     // The returned object will match the caller's string ABI, even when the
     // stored string doesn't.
     template<typename C>
+      _GLIBCXX_DEFAULT_ABI_TAG
       operator basic_string<C>() const
       {
 	if (!_M_dtor)
@@ -226,7 +227,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   namespace // unnamed
   {
     template<typename _CharT>
-      struct numpunct_shim : std::numpunct<_CharT>, facet::__shim
+      struct _GLIBCXX_DEFAULT_ABI_TAG numpunct_shim
+      : std::numpunct<_CharT>, facet::__shim
       {
 	typedef typename numpunct<_CharT>::__cache_type __cache_type;
 
@@ -250,7 +252,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       };
 
     template<typename _CharT>
-      struct collate_shim : std::collate<_CharT>, facet::__shim
+      struct _GLIBCXX_DEFAULT_ABI_TAG collate_shim
+      : std::collate<_CharT>, facet::__shim
       {
 	typedef basic_string<_CharT>	string_type;
 
@@ -275,7 +278,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       };
 
     template<typename _CharT>
-      struct time_get_shim : std::time_get<_CharT>, facet::__shim
+      struct _GLIBCXX_DEFAULT_ABI_TAG time_get_shim
+      : std::time_get<_CharT>, facet::__shim
       {
 	typedef typename std::time_get<_CharT>::iter_type iter_type;
 	typedef typename std::time_get<_CharT>::char_type char_type;
@@ -329,7 +333,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       };
 
     template<typename _CharT, bool _Intl>
-      struct moneypunct_shim : std::moneypunct<_CharT, _Intl>, facet::__shim
+      struct _GLIBCXX_DEFAULT_ABI_TAG moneypunct_shim
+      : std::moneypunct<_CharT, _Intl>, facet::__shim
       {
 	typedef typename moneypunct<_CharT, _Intl>::__cache_type __cache_type;
 
@@ -356,7 +361,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       };
 
     template<typename _CharT>
-      struct money_get_shim : std::money_get<_CharT>, facet::__shim
+      struct _GLIBCXX_DEFAULT_ABI_TAG money_get_shim
+      : std::money_get<_CharT>, facet::__shim
       {
 	typedef typename std::money_get<_CharT>::iter_type iter_type;
 	typedef typename std::money_get<_CharT>::char_type char_type;
@@ -397,7 +403,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       };
 
     template<typename _CharT>
-      struct money_put_shim : std::money_put<_CharT>, facet::__shim
+      struct _GLIBCXX_DEFAULT_ABI_TAG money_put_shim
+      : std::money_put<_CharT>, facet::__shim
       {
 	typedef typename std::money_put<_CharT>::iter_type iter_type;
 	typedef typename std::money_put<_CharT>::char_type char_type;
@@ -426,7 +433,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       };
 
     template<typename _CharT>
-      struct messages_shim : std::messages<_CharT>, facet::__shim
+      struct _GLIBCXX_DEFAULT_ABI_TAG messages_shim
+      : std::messages<_CharT>, facet::__shim
       {
 	typedef messages_base::catalog  catalog;
 	typedef basic_string<_CharT>	string_type;
diff --git a/libstdc++-v3/src/c++11/future.cc b/libstdc++-v3/src/c++11/future.cc
index 3cf503b..21dbd8a 100644
--- a/libstdc++-v3/src/c++11/future.cc
+++ b/libstdc++-v3/src/c++11/future.cc
@@ -32,6 +32,7 @@ namespace
     name() const noexcept
     { return "future"; }
 
+    _GLIBCXX_DEFAULT_ABI_TAG
     virtual std::string message(int __ec) const
     {
       std::string __msg;
diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc
index 71f5c8b..b7ac1f8 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -41,6 +41,7 @@ namespace
     name() const noexcept
     { return "generic"; }
 
+    _GLIBCXX_DEFAULT_ABI_TAG
     virtual string 
     message(int i) const
     {
@@ -56,6 +57,7 @@ namespace
     name() const noexcept
     { return "system"; }
 
+    _GLIBCXX_DEFAULT_ABI_TAG
     virtual string
     message(int i) const
     {
@@ -111,6 +113,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
 #if _GLIBCXX_USE_DUAL_ABI
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wabi-tag"
   // Redefine __sso_string so that we can define and export its members
   // in terms of the SSO std::string.
   struct __sso_string
@@ -137,6 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __sso_string(__sso_string&&) noexcept;
     __sso_string& operator=(__sso_string&&) noexcept;
   };
+#pragma GCC diagnostic pop
 
   __sso_string::__sso_string() : _M_str() { }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]