===================================================================
@@ -1562,8 +1562,10 @@
from inttypes.h, we generate a warning and treat the ud-suffix as a
separate preprocessing token. This approach is under discussion by
the standards committee, and has been adopted as a conforming
- extension by other front ends such as clang. */
- if (ISALPHA (*cur))
+ extension by other front ends such as clang.
+ A special exception is made for the suffix 's' which will be
+ standardized as a user-defined literal suffix for strings. */
+ if (ISALPHA (*cur) && *cur != 's')
{
/* Raise a warning, but do not consume subsequent tokens. */
if (CPP_OPTION (pfile, warn_literal_suffix))
@@ -1573,7 +1575,7 @@
"a space between literal and identifier");
}
/* Grab user defined literal suffix. */
- else if (*cur == '_')
+ else if (ISIDST (*cur))
{
type = cpp_userdef_string_add_type (type);
++cur;
@@ -1693,8 +1695,10 @@
from inttypes.h, we generate a warning and treat the ud-suffix as a
separate preprocessing token. This approach is under discussion by
the standards committee, and has been adopted as a conforming
- extension by other front ends such as clang. */
- if (ISALPHA (*cur))
+ extension by other front ends such as clang.
+ A special exception is made for the suffix 's' which will be
+ standardized as a user-defined literal suffix for strings. */
+ if (ISALPHA (*cur) && *cur != 's')
{
/* Raise a warning, but do not consume subsequent tokens. */
if (CPP_OPTION (pfile, warn_literal_suffix))
@@ -1704,7 +1708,7 @@
"a space between literal and identifier");
}
/* Grab user defined literal suffix. */
- else if (*cur == '_')
+ else if (ISIDST (*cur))
{
type = cpp_userdef_char_add_type (type);
type = cpp_userdef_string_add_type (type);
===================================================================
@@ -0,0 +1,12 @@
+// { dg-options "-std=c++11" }
+// PR c++/55582
+
+#include "udlit-string-literal.h"
+
+using namespace my_string_literals;
+
+decltype("Hello, World!"s) s;
+decltype(u8"Hello, World!"s) s8;
+decltype(L"Hello, World!"s) ws;
+decltype(u"Hello, World!"s) s16;
+decltype(U"Hello, World!"s) s32;
===================================================================
@@ -0,0 +1,22 @@
+#pragma GCC system_header
+
+#include <string>
+
+inline namespace my_string_literals
+{
+ std::string
+ operator"" s(const char* str, std::size_t len)
+ { return std::string{str, len}; }
+
+ std::wstring
+ operator"" s(const wchar_t* str, std::size_t len)
+ { return std::wstring{str, len}; }
+
+ std::u16string
+ operator"" s(const char16_t* str, std::size_t len)
+ { return std::u16string{str, len}; }
+
+ std::u32string
+ operator"" s(const char32_t* str, std::size_t len)
+ { return std::u32string{str, len}; }
+}