[PATCH] D41064: Suppress -Wuser-defined-literals for <string> and <string_view>
Dimitry Andric via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 11 04:37:22 PST 2017
dim created this revision.
When compiling <string> and/or <string_view> with -Wsystem-headers, in
C++14 or higher mode, clang produces warnings about the literal suffixes
defined in them, e.g.:
$ cat test.cpp
#include <string>
$ clang -std=c++14 -Wsystem-headers -Wall -Wextra -c test.cpp
In file included from test.cpp:1:
In file included from /usr/include/c++/v1/string:470:
/usr/include/c++/v1/string_view:763:29: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string_view<char> operator "" sv(const char *__str, size_t __len)
^
/usr/include/c++/v1/string_view:769:32: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
^
/usr/include/c++/v1/string_view:775:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
^
/usr/include/c++/v1/string_view:781:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
^
In file included from test.cpp:1:
/usr/include/c++/v1/string:4012:24: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string<char> operator "" s( const char *__str, size_t __len )
^
/usr/include/c++/v1/string:4018:27: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
^
/usr/include/c++/v1/string:4024:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
^
/usr/include/c++/v1/string:4030:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
^
8 warnings generated.
Similar to what is done in <exception>, suppress these warnings using
`#pragma clang diagnostic`.
Repository:
rCXX libc++
https://reviews.llvm.org/D41064
Files:
include/string
include/string_view
Index: include/string_view
===================================================================
--- include/string_view
+++ include/string_view
@@ -792,6 +792,10 @@
{
inline namespace string_view_literals
{
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wuser-defined-literals"
+#endif
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
basic_string_view<char> operator "" sv(const char *__str, size_t __len) _NOEXCEPT
{
@@ -815,6 +819,9 @@
{
return basic_string_view<char32_t> (__str, __len);
}
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
}
}
#endif
Index: include/string
===================================================================
--- include/string
+++ include/string
@@ -4042,6 +4042,10 @@
{
inline namespace string_literals
{
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wuser-defined-literals"
+#endif
inline _LIBCPP_INLINE_VISIBILITY
basic_string<char> operator "" s( const char *__str, size_t __len )
{
@@ -4065,6 +4069,9 @@
{
return basic_string<char32_t> (__str, __len);
}
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
}
}
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41064.126339.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171211/842f9f58/attachment.bin>
More information about the cfe-commits
mailing list