[PATCH] Fix unused private field warning in stdexcept after r207695
Dimitry Andric
dimitry at andric.com
Sun Jan 4 07:24:35 PST 2015
Hi joerg, mclow.lists,
As I mentioned on IRC, r207695 leads to a warning when compiling <stdexcept> (or any other header that includes it), if you use -Wsystem-headers, like we do in FreeBSD:
In file included from test-stdexcept.cpp:1:
In file included from include/array:109:
include/stdexcept:56:17: warning: private field '__imp_' is not used [-Wunused-private-field]
const char *__imp_;
^
1 warning generated.
Apart from just including <__refstring> in stdexcept, which is apparently too costly, the fix with lowest impact would probably be to add __attribute__((__unused__)) to the __imp_ field.
However, there isn't any _LIBCPP_UNUSED define in __config yet, so that would have to be added, like in this proposed change.
Somebody who knows about Microsoft C++ and IBM C++ should fill in the unused attribute syntax appropriate for those compilers, if there is any.
http://reviews.llvm.org/D6836
Files:
include/__config
include/stdexcept
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -259,6 +259,8 @@
# define _LIBCPP_NORETURN __attribute__ ((noreturn))
#endif
+#define _LIBCPP_UNUSED __attribute__((__unused__))
+
#if !(__has_feature(cxx_defaulted_functions))
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif // !(__has_feature(cxx_defaulted_functions))
@@ -381,6 +383,8 @@
#define _LIBCPP_NORETURN __attribute__((noreturn))
+#define _LIBCPP_UNUSED __attribute__((__unused__))
+
#if _GNUC_VER >= 407
#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
@@ -478,6 +482,7 @@
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#define __alignof__ __alignof
#define _LIBCPP_NORETURN __declspec(noreturn)
+#define _LIBCPP_UNUSED
#define _ALIGNAS(x) __declspec(align(x))
#define _LIBCPP_HAS_NO_VARIADICS
@@ -501,6 +506,7 @@
#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
#define _ATTRIBUTE(x) __attribute__((x))
#define _LIBCPP_NORETURN __attribute__((noreturn))
+#define _LIBCPP_UNUSED
#define _NOEXCEPT throw()
#define _NOEXCEPT_(x)
Index: include/stdexcept
===================================================================
--- include/stdexcept
+++ include/stdexcept
@@ -53,7 +53,7 @@
#ifndef _LIBCPP___REFSTRING
_LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_HIDDEN __libcpp_refstring {
- const char *__imp_;
+ const char *__imp_ _LIBCPP_UNUSED;
};
_LIBCPP_END_NAMESPACE_STD
#endif
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6836.17776.patch
Type: text/x-patch
Size: 1542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150104/296257c0/attachment.bin>
More information about the cfe-commits
mailing list