@@ -4032,6 +4032,18 @@ bool b = e <= 3.7;
@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
by @option{-Wenum-conversion}.
+@opindex Wdeprecated-literal-operator
+@opindex Wno-deprecated-literal-operator
+@item -Wdeprecated-literal-operator @r{(C++ and Objective-C++ only)}
+Warn that the declaration of a user-defined literal operator with a
+space before the suffix is deprecated. This warning is enabled by
+default in C++23.
+
+@smallexample
+string operator "" _i18n(const char*, std::size_t); // deprecated
+string operator ""_i18n(const char*, std::size_t); // preferred
+@end smallexample
+
@opindex Welaborated-enum-base
@opindex Wno-elaborated-enum-base
@item -Wno-elaborated-enum-base
@@ -664,6 +664,10 @@ C++ ObjC++ Var(warn_deprecated_enum_float_conv) Warning
Warn about deprecated arithmetic conversions on operands where one is of enumeration
type and the other is of a floating-point type.
+Wdeprecated-literal-operator
+C++ ObjC++ Var(warn_deprecated_literal_operator) Warning
+Warn about deprecated space between "" and suffix in a user-defined literal operator.
+
Wdesignated-init
C ObjC Var(warn_designated_init) Init(1) Warning
Warn about positional initialization of structs requiring designated initializers.
@@ -5,24 +5,24 @@
inline namespace my_string_literals
{
std::string
- operator"" s(const char* str, std::size_t len)
+ operator ""s(const char* str, std::size_t len)
{ return std::string{str, len}; }
#if __cpp_lib_char8_t
std::u8string
- operator"" s(const char8_t* str, std::size_t len)
+ operator ""s(const char8_t* str, std::size_t len)
{ return std::u8string{str, len}; }
#endif
std::wstring
- operator"" s(const wchar_t* str, std::size_t len)
+ 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)
+ 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)
+ operator ""s(const char32_t* str, std::size_t len)
{ return std::u32string{str, len}; }
}
@@ -1016,6 +1016,11 @@ c_common_post_options (const char **pfilename)
warn_deprecated_enum_float_conv,
cxx_dialect >= cxx20 && warn_deprecated);
+ /* -Wdeprecated-literal-operator is enabled by default in C++23. */
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ warn_deprecated_literal_operator,
+ cxx_dialect >= cxx23 && warn_deprecated);
+
/* -Wtemplate-id-cdtor is enabled by default in C++20. */
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
warn_template_id_cdtor,
@@ -943,6 +943,18 @@ make_location (cp_token *caret, cp_token *start, cp_token *end)
return make_location (caret->location, start->location, end->location);
}
+/* Location for the whitespace between two tokens. */
+
+static location_t
+location_between (cp_token *stok, cp_token *etok)
+{
+ location_t s = get_finish (stok->location);
+ s = linemap_position_for_loc_and_offset (line_table, s, 1);
+ location_t e = get_start (etok->location);
+ e = linemap_position_for_loc_and_offset (line_table, e, -1);
+ return make_location (s, s, e);
+}
+
/* nonzero if we are presently saving tokens. */
static inline int
@@ -18325,6 +18337,8 @@ cp_parser_operator (cp_parser* parser, location_t start_loc)
if (cxx_dialect == cxx98)
maybe_warn_cpp0x (CPP0X_USER_DEFINED_LITERALS);
+ token = cp_lexer_peek_token (parser->lexer);
+
/* Consume the string. */
cp_expr str = cp_parser_userdef_string_literal (parser,
/*lookup_udlit=*/false);
@@ -18340,13 +18354,24 @@ cp_parser_operator (cp_parser* parser, location_t start_loc)
{
string_tree = str;
/* Look for the suffix identifier. */
- token = cp_lexer_peek_token (parser->lexer);
- if (token->type == CPP_NAME)
+ cp_token *id_tok = cp_lexer_peek_token (parser->lexer);
+ if (id_tok->type == CPP_NAME)
{
id = cp_parser_identifier (parser);
- end_loc = token->location;
+ end_loc = id_tok->location;
+
+ /* Deprecated by CWG2521 in C++23. */
+ if (warn_deprecated_literal_operator)
+ {
+ gcc_rich_location
+ space (location_between (token, id_tok));
+ space.add_fixit_remove ();
+ warning_at (&space, OPT_Wdeprecated_literal_operator,
+ "space between quotes and suffix is "
+ "deprecated in C++23");
+ }
}
- else if (token->type == CPP_KEYWORD)
+ else if (id_tok->type == CPP_KEYWORD)
{
error ("unexpected keyword;"
" remove space between quotes and suffix identifier");
new file mode 100644
@@ -0,0 +1,5 @@
+// CWG2521
+// { dg-do compile { target c++11 } }
+
+void operator "" _foo(const char *); // { dg-warning "deprecated" "" { target c++23 } }
+void operator ""_bar(const char *);
@@ -5,7 +5,8 @@
// Test "-Wno-literal-suffix" suppresses warnings on declaration without
// leading underscore.
-long double operator"" nounder(long double); // { dg-bogus "" }
+long double operator"" nounder(long double); // { dg-bogus "reserved" }
+// { dg-warning "space" "" { target c++23 } .-1 }
template<char...>
- int operator"" nounder(); // { dg-bogus "" }
+ int operator ""nounder(); // { dg-bogus "reserved" }
@@ -11,7 +11,7 @@ constexpr unsigned long long mymax(A && a,const B& b){
}
template<char... List>
-constexpr long long operator"" _y() noexcept
+constexpr long long operator ""_y() noexcept
{
return AA<1, mymax(1,2)>::val; // <-- crashes gcc
// return mymax(1,2); // <-- compiles
@@ -4,73 +4,73 @@
// Integer imaginary...
constexpr unsigned long long
-operator"" i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } }
+operator ""i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } }
{ return 4 * n + 0; }
constexpr unsigned long long
-operator"" I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" }
+operator ""I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" }
{ return 4 * n + 1; }
constexpr unsigned long long
-operator"" j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" }
+operator ""j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" }
{ return 4 * n + 2; }
constexpr unsigned long long
-operator"" J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" }
+operator ""J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" }
{ return 4 * n + 3; }
// Floating-point imaginary...
constexpr long double
-operator"" i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } }
+operator ""i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } }
{ return 4.0L * n + 0.0L; }
constexpr long double
-operator"" I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" }
+operator ""I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" }
{ return 4.0L * n + 1.0L; }
constexpr long double
-operator"" j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" }
+operator ""j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" }
{ return 4.0L * n + 2.0L; }
constexpr long double
-operator"" J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" }
+operator ""J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" }
{ return 4.0L * n + 3.0L; }
// Fixed-point...
constexpr long double
-operator"" k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" }
+operator ""k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" }
{ return 4 * (n + 1) + 0; }
constexpr long double
-operator"" K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" }
+operator ""K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" }
{ return 4 * (n + 1) + 1; }
constexpr long double
-operator"" r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" }
+operator ""r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" }
{ return 4 * (n + 1) + 2; }
constexpr long double
-operator"" R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" }
+operator ""R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" }
{ return 4 * (n + 1) + 3; }
// Machine-defined...
constexpr long double
-operator"" w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" }
+operator ""w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" }
{ return 4 * (n + 2) + 0; }
constexpr long double
-operator"" W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" }
+operator ""W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" }
{ return 4 * (n + 2) + 1; }
constexpr long double
-operator"" q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" }
+operator ""q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" }
{ return 4 * (n + 2) + 2; }
constexpr long double
-operator"" Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" }
+operator ""Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" }
{ return 4 * (n + 2) + 3; }
int
@@ -4,73 +4,73 @@
// Integer imaginary...
constexpr unsigned long long
-operator"" i(unsigned long long n)
+operator ""i(unsigned long long n)
{ return 4 * n + 0; }
constexpr unsigned long long
-operator"" I(unsigned long long n)
+operator ""I(unsigned long long n)
{ return 4 * n + 1; }
constexpr unsigned long long
-operator"" j(unsigned long long n)
+operator ""j(unsigned long long n)
{ return 4 * n + 2; }
constexpr unsigned long long
-operator"" J(unsigned long long n)
+operator ""J(unsigned long long n)
{ return 4 * n + 3; }
// Floating-point imaginary...
constexpr long double
-operator"" i(long double n)
+operator ""i(long double n)
{ return 4.0L * n + 0.0L; }
constexpr long double
-operator"" I(long double n)
+operator ""I(long double n)
{ return 4.0L * n + 1.0L; }
constexpr long double
-operator"" j(long double n)
+operator ""j(long double n)
{ return 4.0L * n + 2.0L; }
constexpr long double
-operator"" J(long double n)
+operator ""J(long double n)
{ return 4.0L * n + 3.0L; }
// Fixed-point...
constexpr long double
-operator"" k(long double n)
+operator ""k(long double n)
{ return 4 * (n + 1) + 0; }
constexpr long double
-operator"" K(long double n)
+operator ""K(long double n)
{ return 4 * (n + 1) + 1; }
constexpr long double
-operator"" r(long double n)
+operator ""r(long double n)
{ return 4 * (n + 1) + 2; }
constexpr long double
-operator"" R(long double n)
+operator ""R(long double n)
{ return 4 * (n + 1) + 3; }
// Machine-defined...
constexpr long double
-operator"" w(long double n)
+operator ""w(long double n)
{ return 4 * (n + 2) + 0; }
constexpr long double
-operator"" W(long double n)
+operator ""W(long double n)
{ return 4 * (n + 2) + 1; }
constexpr long double
-operator"" q(long double n)
+operator ""q(long double n)
{ return 4 * (n + 2) + 2; }
constexpr long double
-operator"" Q(long double n)
+operator ""Q(long double n)
{ return 4 * (n + 2) + 3; }
int
@@ -4,9 +4,9 @@
void
foo()
{
- float x = operator"" _F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" }
+ float x = operator ""_F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" }
/* { dg-begin-multiline-output "" }
- float x = operator"" _F();
+ float x = operator ""_F();
^~~~~~~~~~~~~
{ dg-end-multiline-output "" } */
@@ -4,25 +4,25 @@
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1473
void operator "" "boo" _ya(unsigned long long); // { dg-error "expected empty string after" }
+// { dg-warning "space" "" { target c++23 } .-1 }
void operator "" "boo"_ya(unsigned long long); // { dg-error "expected empty string after" }
-void operator "" u"" _u(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
+void operator "" u""_u(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
-void operator u"" "" _v(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
+void operator u"" ""_v(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
-void operator U"" "" _w(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
+void operator U"" ""_w(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
-void operator L"" "" _x(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
+void operator L"" ""_x(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
-void operator u8"" "" _y(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
+void operator u8"" ""_y(unsigned long long); // { dg-error "invalid encoding prefix in literal operator" }
-void operator u"" L"" _z(unsigned long long); // { dg-error "concatenation of string literals with conflicting encoding prefixes" }
+void operator u"" L""_z(unsigned long long); // { dg-error "concatenation of string literals with conflicting encoding prefixes" }
+// { dg-error "invalid encoding prefix in literal operator" "invalid" { target *-*-* } .-1 }
void operator ""_p ""_q(unsigned long long); // { dg-error "inconsistent user-defined literal suffixes" }
void operator "" "" while(unsigned long long); // { dg-error "unexpected keyword; remove space between quotes and suffix identifier" }
void operator "" ""(unsigned long long); // { dg-error "expected suffix identifier" }
-
-// { dg-error "invalid encoding prefix in literal operator" "invalid" { target *-*-* } 20 }
@@ -4,8 +4,10 @@
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1473
void operator "" "" _x(unsigned long long);
+// { dg-warning "space" "" { target c++23 } .-1 }
void operator "" "" "" _x(unsigned long long);
+// { dg-warning "space" "" { target c++23 } .-1 }
void operator "" ""_w(unsigned long long);
@@ -6,11 +6,11 @@
#include <cstdlib>
void
-operator "" _s(const char *, size_t)
+operator ""_s(const char *, size_t)
{ }
void
-operator "" _t(const char)
+operator ""_t(const char)
{ }
#define QUOTE(s) #s
@@ -4,73 +4,73 @@
// Integer imaginary...
constexpr unsigned long long
-operator"" i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } }
+operator ""i(unsigned long long n) // { dg-warning "1:integer suffix .i. shadowed by implementation" "" { target c++11_only } }
{ return 4 * n + 0; }
constexpr unsigned long long
-operator"" I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" }
+operator ""I(unsigned long long n) // { dg-warning "1:integer suffix .I. shadowed by implementation" }
{ return 4 * n + 1; }
constexpr unsigned long long
-operator"" j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" }
+operator ""j(unsigned long long n) // { dg-warning "1:integer suffix .j. shadowed by implementation" }
{ return 4 * n + 2; }
constexpr unsigned long long
-operator"" J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" }
+operator ""J(unsigned long long n) // { dg-warning "1:integer suffix .J. shadowed by implementation" }
{ return 4 * n + 3; }
// Floating-point imaginary...
constexpr long double
-operator"" i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } }
+operator ""i(long double n) // { dg-warning "1:floating-point suffix .i. shadowed by implementation" "" { target c++11_only } }
{ return 4.0L * n + 0.0L; }
constexpr long double
-operator"" I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" }
+operator ""I(long double n) // { dg-warning "1:floating-point suffix .I. shadowed by implementation" }
{ return 4.0L * n + 1.0L; }
constexpr long double
-operator"" j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" }
+operator ""j(long double n) // { dg-warning "1:floating-point suffix .j. shadowed by implementation" }
{ return 4.0L * n + 2.0L; }
constexpr long double
-operator"" J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" }
+operator ""J(long double n) // { dg-warning "1:floating-point suffix .J. shadowed by implementation" }
{ return 4.0L * n + 3.0L; }
// Fixed-point...
constexpr long double
-operator"" k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" }
+operator ""k(long double n) // { dg-warning "1:floating-point suffix .k. shadowed by implementation" }
{ return 4 * (n + 1) + 0; }
constexpr long double
-operator"" K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" }
+operator ""K(long double n) // { dg-warning "1:floating-point suffix .K. shadowed by implementation" }
{ return 4 * (n + 1) + 1; }
constexpr long double
-operator"" r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" }
+operator ""r(long double n) // { dg-warning "1:floating-point suffix .r. shadowed by implementation" }
{ return 4 * (n + 1) + 2; }
constexpr long double
-operator"" R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" }
+operator ""R(long double n) // { dg-warning "1:floating-point suffix .R. shadowed by implementation" }
{ return 4 * (n + 1) + 3; }
// Machine-defined...
constexpr long double
-operator"" w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" }
+operator ""w(long double n) // { dg-warning "1:floating-point suffix .w. shadowed by implementation" }
{ return 4 * (n + 2) + 0; }
constexpr long double
-operator"" W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" }
+operator ""W(long double n) // { dg-warning "1:floating-point suffix .W. shadowed by implementation" }
{ return 4 * (n + 2) + 1; }
constexpr long double
-operator"" q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" }
+operator ""q(long double n) // { dg-warning "1:floating-point suffix .q. shadowed by implementation" }
{ return 4 * (n + 2) + 2; }
constexpr long double
-operator"" Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" }
+operator ""Q(long double n) // { dg-warning "1:floating-point suffix .Q. shadowed by implementation" }
{ return 4 * (n + 2) + 3; }
int
@@ -4,73 +4,73 @@
// Integer imaginary...
constexpr unsigned long long
-operator"" i(unsigned long long n)
+operator ""i(unsigned long long n)
{ return 4 * n + 0; }
constexpr unsigned long long
-operator"" I(unsigned long long n)
+operator ""I(unsigned long long n)
{ return 4 * n + 1; }
constexpr unsigned long long
-operator"" j(unsigned long long n)
+operator ""j(unsigned long long n)
{ return 4 * n + 2; }
constexpr unsigned long long
-operator"" J(unsigned long long n)
+operator ""J(unsigned long long n)
{ return 4 * n + 3; }
// Floating-point imaginary...
constexpr long double
-operator"" i(long double n)
+operator ""i(long double n)
{ return 4.0L * n + 0.0L; }
constexpr long double
-operator"" I(long double n)
+operator ""I(long double n)
{ return 4.0L * n + 1.0L; }
constexpr long double
-operator"" j(long double n)
+operator ""j(long double n)
{ return 4.0L * n + 2.0L; }
constexpr long double
-operator"" J(long double n)
+operator ""J(long double n)
{ return 4.0L * n + 3.0L; }
// Fixed-point...
constexpr long double
-operator"" k(long double n)
+operator ""k(long double n)
{ return 4 * (n + 1) + 0; }
constexpr long double
-operator"" K(long double n)
+operator ""K(long double n)
{ return 4 * (n + 1) + 1; }
constexpr long double
-operator"" r(long double n)
+operator ""r(long double n)
{ return 4 * (n + 1) + 2; }
constexpr long double
-operator"" R(long double n)
+operator ""R(long double n)
{ return 4 * (n + 1) + 3; }
// Machine-defined...
constexpr long double
-operator"" w(long double n)
+operator ""w(long double n)
{ return 4 * (n + 2) + 0; }
constexpr long double
-operator"" W(long double n)
+operator ""W(long double n)
{ return 4 * (n + 2) + 1; }
constexpr long double
-operator"" q(long double n)
+operator ""q(long double n)
{ return 4 * (n + 2) + 2; }
constexpr long double
-operator"" Q(long double n)
+operator ""Q(long double n)
{ return 4 * (n + 2) + 3; }
int
@@ -2,9 +2,9 @@
#include <cstddef>
-bool operator"" _yn(const char*, size_t);
+bool operator ""_yn(const char*, size_t);
typedef bool (*pfunk)(const char*, size_t);
-pfunk p = &operator"" _yn;
+pfunk p = &operator ""_yn;
bool tf = p("Hello,\0 World!", 14);
@@ -5,37 +5,37 @@
class Foo { };
int
-operator"" _Foo(); // { dg-error "1:.int operator\"\"_Foo\\(\\). has invalid argument list" }
+operator ""_Foo(); // { dg-error "1:.int operator\"\"_Foo\\(\\). has invalid argument list" }
Foo
-operator"" _Foo(int *); // { dg-error "1:.Foo operator\"\"_Foo\\(int\\*\\). has invalid argument list" }
+operator ""_Foo(int *); // { dg-error "1:.Foo operator\"\"_Foo\\(int\\*\\). has invalid argument list" }
Foo
-operator"" _Foo(unsigned long int); // { dg-error "1:.Foo operator\"\"_Foo\\(long unsigned int\\). has invalid argument list" }
+operator ""_Foo(unsigned long int); // { dg-error "1:.Foo operator\"\"_Foo\\(long unsigned int\\). has invalid argument list" }
Foo
-operator"" _Foo(double); // { dg-error "1:.Foo operator\"\"_Foo\\(double\\). has invalid argument list" }
+operator ""_Foo(double); // { dg-error "1:.Foo operator\"\"_Foo\\(double\\). has invalid argument list" }
Foo
-operator"" _Foo(const float *, std::size_t); // { dg-error "1:.Foo operator\"\"_Foo\\(const float\\*, std::size_t\\). has invalid argument list" }
+operator ""_Foo(const float *, std::size_t); // { dg-error "1:.Foo operator\"\"_Foo\\(const float\\*, std::size_t\\). has invalid argument list" }
Foo
-operator"" _Foo(const wchar_t *, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const wchar_t\\*, int\\). has invalid argument list" }
+operator ""_Foo(const wchar_t *, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const wchar_t\\*, int\\). has invalid argument list" }
Foo
-operator"" _Foo(const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(const char16_t\\*\\). has invalid argument list" }
+operator ""_Foo(const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(const char16_t\\*\\). has invalid argument list" }
Foo
-operator"" _Foo(char...); // { dg-error "1:.Foo operator\"\"_Foo\\(char, \\.\\.\\.\\). has invalid argument list" }
+operator ""_Foo(char...); // { dg-error "1:.Foo operator\"\"_Foo\\(char, \\.\\.\\.\\). has invalid argument list" }
Foo
-operator"" _Foo(unsigned long long int, char); // { dg-error "1:.Foo operator\"\"_Foo\\(long long unsigned int, char\\). has invalid argument list" }
+operator ""_Foo(unsigned long long int, char); // { dg-error "1:.Foo operator\"\"_Foo\\(long long unsigned int, char\\). has invalid argument list" }
Foo
-operator"" _Foo(const char *, std::size_t, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const char\\*, std::size_t, int\\). has invalid argument list" }
+operator ""_Foo(const char *, std::size_t, int); // { dg-error "1:.Foo operator\"\"_Foo\\(const char\\*, std::size_t, int\\). has invalid argument list" }
Foo
-operator"" _Foo(long double &); // { dg-error "1:.Foo operator\"\"_Foo\\(long double&\\). has invalid argument list" }
+operator ""_Foo(long double &); // { dg-error "1:.Foo operator\"\"_Foo\\(long double&\\). has invalid argument list" }
Foo
-operator"" _Foo(std::size_t, const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(std::size_t, const char16_t\\*\\). has invalid argument list" }
+operator ""_Foo(std::size_t, const char16_t *); // { dg-error "1:.Foo operator\"\"_Foo\\(std::size_t, const char16_t\\*\\). has invalid argument list" }
@@ -5,34 +5,34 @@
class Foo { };
Foo
-operator"" _Foo(const char *);
+operator ""_Foo(const char *);
Foo
-operator"" _Foo(unsigned long long int);
+operator ""_Foo(unsigned long long int);
Foo
-operator"" _Foo(long double);
+operator ""_Foo(long double);
Foo
-operator"" _Foo(char);
+operator ""_Foo(char);
Foo
-operator"" _Foo(wchar_t);
+operator ""_Foo(wchar_t);
Foo
-operator"" _Foo(char16_t);
+operator ""_Foo(char16_t);
Foo
-operator"" _Foo(char32_t);
+operator ""_Foo(char32_t);
Foo
-operator"" _Foo(const char *, std::size_t);
+operator ""_Foo(const char *, std::size_t);
Foo
-operator"" _Foo(const wchar_t *, std::size_t);
+operator ""_Foo(const wchar_t *, std::size_t);
Foo
-operator"" _Foo(const char16_t *, std::size_t);
+operator ""_Foo(const char16_t *, std::size_t);
Foo
-operator"" _Foo(const char32_t *, std::size_t);
+operator ""_Foo(const char32_t *, std::size_t);
@@ -3,12 +3,12 @@
#include <cstddef>
-int operator "" _a (const char *);
-int operator "" _a (const char *, std::size_t);
+int operator ""_a (const char *);
+int operator ""_a (const char *, std::size_t);
int a = 123_a;
int a2 = "abc"_a;
-int operator "" _b (const char *, std::size_t);
-int operator "" _b (const char *);
+int operator ""_b (const char *, std::size_t);
+int operator ""_b (const char *);
int b = 123_b;
int b2 = "abc"_b;
@@ -3,6 +3,6 @@
extern "C" {
int
-operator"" _badclinkage(unsigned long long); // { dg-error "1:literal operator with C linkage" }
+operator ""_badclinkage(unsigned long long); // { dg-error "1:literal operator with C linkage" }
}
@@ -3,8 +3,8 @@
#include <string>
-std::string operator"" _xxx(const char*, size_t);
+std::string operator ""_xxx(const char*, size_t);
-std::string operator"" _yyy(const char*, size_t);
+std::string operator ""_yyy(const char*, size_t);
std::string concat = "Hello, "_xxx "World!"_yyy; // { dg-error "inconsistent user-defined literal suffixes" }
@@ -3,7 +3,7 @@
#include <string>
-std::string operator"" _www(const char*, size_t);
+std::string operator ""_www(const char*, size_t);
std::string concat01 = "Hello, " "World!"_www;
@@ -14,9 +14,9 @@ std::string concat11 = "Hello, "_www "World!"_www;
class Tachyon { };
-Tachyon operator"" _fast(const char*, size_t);
+Tachyon operator ""_fast(const char*, size_t);
-int operator"" _fast(const char32_t*, size_t);
+int operator ""_fast(const char32_t*, size_t);
int speedy01 = "Hello, " U"World!"_fast;
@@ -1,7 +1,7 @@
// { dg-do compile { target c++11 } }
constexpr unsigned long long
-operator"" _grow(unsigned long long n)
+operator ""_grow(unsigned long long n)
{ return 2 * n; }
double buffer[25_grow];
@@ -3,13 +3,13 @@
#include <cstddef>
int
-operator"" _mm(long double m) // { dg-warning "user-defined literals only available with" }
+operator ""_mm(long double m) // { dg-warning "user-defined literals only available with" }
{ return int(1000.0L * m); }
int in = 0.0254_mm; // { dg-error "invalid suffix" }
int
-operator"" _Q(const char *, std::size_t) // { dg-warning "user-defined literals only available with" }
+operator ""_Q(const char *, std::size_t) // { dg-warning "user-defined literals only available with" }
{ return 42; }
int x = "Hello"_Q; // { dg-error "invalid conversion from" "invalid" }
@@ -2,14 +2,14 @@
// Check that undeclared literal operator calls and literals give appropriate errors.
-int i = operator"" _Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
+int i = operator ""_Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
int j = 'x'_Bar; // { dg-error "unable to find character literal operator|with|argument" }
-int ii = operator"" _BarCharStr("Howdy, Pardner!"); // { dg-error "10:'operator\"\"_BarCharStr' was not declared in this scope" }
+int ii = operator ""_BarCharStr("Howdy, Pardner!"); // { dg-error "10:'operator\"\"_BarCharStr' was not declared in this scope" }
int jj = "Howdy, Pardner!"_BarCharStr; // { dg-error "unable to find string literal operator|Possible missing length argument" }
-unsigned long long iULL = operator"" _BarULL(666ULL); // { dg-error "27:'operator\"\"_BarULL' was not declared in this scope" }
+unsigned long long iULL = operator ""_BarULL(666ULL); // { dg-error "27:'operator\"\"_BarULL' was not declared in this scope" }
unsigned long long jULL = 666_BarULL; // { dg-error "unable to find numeric literal operator" }
-long double iLD = operator"" _BarLD(666.0L); // { dg-error "19:'operator\"\"_BarLD' was not declared in this scope" }
+long double iLD = operator ""_BarLD(666.0L); // { dg-error "19:'operator\"\"_BarLD' was not declared in this scope" }
long double jLD = 666.0_BarLD; // { dg-error "unable to find numeric literal operator" }
@@ -6,10 +6,10 @@
#include <cstdint>
#include <cassert>
-int operator"" _embedchar(char)
+int operator ""_embedchar(char)
{ return 41; }
-int operator"" _embedstr(const char*, std::size_t len)
+int operator ""_embedstr(const char*, std::size_t len)
{ return 42 + len; }
void
@@ -1,5 +1,5 @@
// { dg-do run { target c++11 } }
-// { dg-additional-options "-Wno-error=normalized" }
+// { dg-additional-options "-Wno-error=normalized -Wno-deprecated-literal-operator" }
// { dg-require-effective-target ucn }
// { dg-skip-if "requires hosted libstdc++ for cstring" { ! hostedlib } }
@@ -7,7 +7,7 @@
#include <cstddef>
using namespace std;
-constexpr unsigned long long operator "" _Ï€ (unsigned long long x)
+constexpr unsigned long long operator ""_Ï€ (unsigned long long x)
{
return 3 * x;
}
@@ -25,7 +25,7 @@ char x2[2_Î 2];
static_assert (sizeof x1 == 3, "test1");
static_assert (sizeof x2 == 8, "test2");
-const char * operator "" _1σ (const char *s, size_t)
+const char * operator ""_1σ (const char *s, size_t)
{
return s + 1;
}
@@ -35,7 +35,7 @@ const char * operator ""_Σ2 (const char *s, size_t)
return s + 2;
}
-const char * operator "" _\U000000e61 (const char *s, size_t)
+const char * operator ""_\U000000e61 (const char *s, size_t)
{
return "ae";
}
@@ -45,7 +45,7 @@ const char* operator ""_\u01532 (const char *s, size_t)
return "oe";
}
-bool operator "" _\u0BC7\u0BBE (unsigned long long); // { dg-warning "not in NFC" }
+bool operator ""_\u0BC7\u0BBE (unsigned long long); // { dg-warning "not in NFC" }
bool operator ""_\u0B47\U00000B3E (unsigned long long); // { dg-warning "not in NFC" }
#define xτy
@@ -14,4 +14,5 @@ const char *x = "hbar"_ħ; // { dg-bogus "poisoned" }
syntax has been deprecated for C++23. */
#pragma GCC poison _ħ2
const char * operator "" _ħ2 (const char *, size_t); // { dg-bogus "poisoned" "" { xfail *-*-*} }
+// { dg-warning "space" "" { target c++23 } .-1 }
const char *x2 = "hbar2"_ħ2; // { dg-bogus "poisoned" }
@@ -2,6 +2,6 @@
extern "C" { // { dg-message "1: 'extern .C.' linkage started here" }
-constexpr double operator"" _deg ( double degrees ); // { dg-error "18:literal operator with C linkage" }
+constexpr double operator ""_deg ( double degrees ); // { dg-error "18:literal operator with C linkage" }
}
@@ -1,28 +1,28 @@
// { dg-do compile { target c++11 } }
long double
-operator"" _Hertz(long double);
+operator ""_Hertz(long double);
class Foo
{
public:
Foo() { }
- friend Foo operator"" _Bar(char);
+ friend Foo operator ""_Bar(char);
friend long double
- operator"" _Hertz(long double omega)
+ operator ""_Hertz(long double omega)
{ return omega / 6.28318530717958648; }
};
Foo
-operator"" _Bar(char)
+operator ""_Bar(char)
{ return Foo(); }
-Foo f1 = operator"" _Bar('x');
+Foo f1 = operator ""_Bar('x');
Foo f2 = 'x'_Bar;
-long double fm1 = operator"" _Hertz(552.92L);
+long double fm1 = operator ""_Hertz(552.92L);
long double fm2 = 552.92_Hertz;
@@ -9,27 +9,27 @@
#include <complex>
#include <cassert>
-long double operator"" _v(long double);
-std::string operator"" _w(const char16_t*, size_t);
-unsigned operator"" _w(const char*);
+long double operator ""_v(long double);
+std::string operator ""_w(const char16_t*, size_t);
+unsigned operator ""_w(const char*);
std::complex<double>
-operator"" _i(long double y)
+operator ""_i(long double y)
{ return std::complex<double>(0.0L, y); }
void
test1()
{
- long double x = operator"" _v(1.2L);
+ long double x = operator ""_v(1.2L);
assert(x == 2.2L);
- std::string s = operator"" _w(u"one", 3);
+ std::string s = operator ""_w(u"one", 3);
assert(s == "boo");
- unsigned u = operator"" _w("Hello, World!");
+ unsigned u = operator ""_w("Hello, World!");
assert(u == 13U);
- std::complex<double> i = operator"" _i(2.0);
+ std::complex<double> i = operator ""_i(2.0);
assert(i == std::complex<double>(0.0, 2.0));
}
@@ -40,13 +40,13 @@ main()
}
long double
-operator"" _v(long double x)
+operator ""_v(long double x)
{ return x + 1.0L; }
std::string
-operator"" _w(const char16_t*, size_t)
+operator ""_w(const char16_t*, size_t)
{ return std::string("boo"); }
unsigned
-operator"" _w(const char* str)
+operator ""_w(const char* str)
{ return strlen(str); }
@@ -2,23 +2,23 @@
#include <cstdint>
-int operator"" _bar (long double);
+int operator ""_bar (long double);
-double operator"" _foo (long long unsigned);
+double operator ""_foo (long long unsigned);
int i = 12_bar; // { dg-error "unable to find numeric literal operator|with|argument" }
double d = 1.2_foo; // { dg-error "unable to find numeric literal operator|with|argument" }
-int operator"" _char(char);
+int operator ""_char(char);
-int operator"" _char8_t(char8_t);
+int operator ""_char8_t(char8_t);
-int operator"" _wchar_t(wchar_t);
+int operator ""_wchar_t(wchar_t);
-int operator"" _char16_t(char16_t);
+int operator ""_char16_t(char16_t);
-int operator"" _char32_t(char32_t);
+int operator ""_char32_t(char32_t);
int cwcx = 'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" }
int cc8 = 'c'_char8_t; // { dg-error "unable to find character literal operator|with|argument" }
@@ -45,15 +45,15 @@ int c32c8 = U'c'_char8_t; // { dg-error "unable to find character literal operat
int c32wc = U'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" }
int c32c16 = U'c'_char16_t; // { dg-error "unable to find character literal operator|with|argument" }
-int operator"" _char_str(const char*, std::size_t);
+int operator ""_char_str(const char*, std::size_t);
-int operator"" _wchar_t_str(const wchar_t*, std::size_t);
+int operator ""_wchar_t_str(const wchar_t*, std::size_t);
-int operator"" _char8_t_str(const char8_t*, std::size_t);
+int operator ""_char8_t_str(const char8_t*, std::size_t);
-int operator"" _char16_t_str(const char16_t*, std::size_t);
+int operator ""_char16_t_str(const char16_t*, std::size_t);
-int operator"" _char32_t_str(const char32_t*, std::size_t);
+int operator ""_char32_t_str(const char32_t*, std::size_t);
int strwstr = "str"_wchar_t_str; // { dg-error "unable to find string literal operator|with|arguments" }
int strstr8 = "str"_char8_t_str; // { dg-error "unable to find string literal operator|with|arguments" }
@@ -2,21 +2,21 @@
#include <cstdint>
-int operator"" _bar (long double);
+int operator ""_bar (long double);
-double operator"" _foo (long long unsigned);
+double operator ""_foo (long long unsigned);
int i = 12_bar; // { dg-error "unable to find numeric literal operator|with|argument" }
double d = 1.2_foo; // { dg-error "unable to find numeric literal operator|with|argument" }
-int operator"" _char(char);
+int operator ""_char(char);
-int operator"" _wchar_t(wchar_t);
+int operator ""_wchar_t(wchar_t);
-int operator"" _char16_t(char16_t);
+int operator ""_char16_t(char16_t);
-int operator"" _char32_t(char32_t);
+int operator ""_char32_t(char32_t);
int cwcx = 'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" }
int cc16 = 'c'_char16_t; // { dg-error "unable to find character literal operator|with|argument" }
@@ -34,13 +34,13 @@ int c32c = U'c'_char; // { dg-error "unable to find character literal operator|w
int c32wc = U'c'_wchar_t; // { dg-error "unable to find character literal operator|with|argument" }
int c32c16 = U'c'_char16_t; // { dg-error "unable to find character literal operator|with|argument" }
-int operator"" _char_str(const char*, std::size_t);
+int operator ""_char_str(const char*, std::size_t);
-int operator"" _wchar_t_str(const wchar_t*, std::size_t);
+int operator ""_wchar_t_str(const wchar_t*, std::size_t);
-int operator"" _char16_t_str(const char16_t*, std::size_t);
+int operator ""_char16_t_str(const char16_t*, std::size_t);
-int operator"" _char32_t_str(const char32_t*, std::size_t);
+int operator ""_char32_t_str(const char32_t*, std::size_t);
int strwstr = "str"_wchar_t_str; // { dg-error "unable to find string literal operator|with|arguments" }
int strstr16 = "str"_char16_t_str; // { dg-error "unable to find string literal operator|with|arguments" }
@@ -3,20 +3,20 @@
// Literal operators can be inline.
inline int
-operator"" _thing1(char cc)
+operator ""_thing1(char cc)
{ return 42 * cc; }
-int operator"" _thing2(char cc);
+int operator ""_thing2(char cc);
class Foo
{
int
- friend operator"" _thing2(char cc)
+ friend operator ""_thing2(char cc)
{ return 42 * cc; }
};
-int i = operator"" _thing1('x');
+int i = operator ""_thing1('x');
int j = 'x'_thing1;
-int iF = operator"" _thing2('x');
+int iF = operator ""_thing2('x');
int jF = 'x'_thing2;
@@ -2,7 +2,7 @@
// { dg-do compile { target c++11 } }
// { dg-final { scan-assembler "_Zli2_wPKc" } }
-int operator "" _w(const char*);
+int operator ""_w(const char*);
int main() {
123_w;
}
@@ -4,12 +4,12 @@ class Foo
{
public:
Foo() { }
- int operator"" _Bar(char32_t); // { dg-error "7:.int Foo::operator\"\"_Bar\\(char32_t\\). must be a non-member function" }
+ int operator ""_Bar(char32_t); // { dg-error "7:.int Foo::operator\"\"_Bar\\(char32_t\\). must be a non-member function" }
};
-int i = operator"" _Bar(U'x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
+int i = operator ""_Bar(U'x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
int j = U'x'_Bar; // { dg-error "unable to find character literal operator" }
int
-Foo::operator"" _Bar(char32_t) // { dg-error "must be a non-member function" }
+Foo::operator ""_Bar(char32_t) // { dg-error "must be a non-member function" }
{ return 42; }
@@ -9,23 +9,23 @@
namespace Long
{
- long double operator"" _LL(long double);
+ long double operator ""_LL(long double);
}
namespace Short
{
short
- operator"" _SS(long double x)
+ operator ""_SS(long double x)
{ return std::fmod(x, static_cast<long double>(std::numeric_limits<short>::max())); }
}
void
test1()
{
- long double x = Long::operator "" _LL(1.2L);
+ long double x = Long::operator ""_LL(1.2L);
using namespace Short;
- short s = operator"" _SS(1.2L);
+ short s = operator ""_SS(1.2L);
short s2 = 1.2_SS;
}
@@ -38,6 +38,6 @@ main()
namespace Long
{
long double
- operator"" _LL(long double x)
+ operator ""_LL(long double x)
{ return x + 2.0L; }
}
@@ -3,7 +3,7 @@
// Test user-defined literals.
// Test error on non-function declaration.
-double operator"" _baddecl; // { dg-error "8:declaration of .operator\"\"_baddecl. as non-function" }
+double operator ""_baddecl; // { dg-error "8:declaration of .operator\"\"_baddecl. as non-function" }
template<char...>
- int operator"" _badtmpldecl; // { dg-error "7:declaration of .operator\"\"_badtmpldecl. as non-function" }
+ int operator ""_badtmpldecl; // { dg-error "7:declaration of .operator\"\"_badtmpldecl. as non-function" }
@@ -3,4 +3,4 @@
// Test user-defined literals.
// Test error on non-empty string after 'operator' keyword.
-double operator"hi" _badword(long double); // { dg-error "expected empty string after" }
+double operator "hi"_badword(long double); // { dg-error "expected empty string after" }
@@ -1,5 +1,5 @@
// { dg-do compile { target c++11 } }
char32_t
-operator"" (char32_t C) // { dg-error "expected suffix identifier" }
+operator ""(char32_t C) // { dg-error "expected suffix identifier" }
{ return C; }
@@ -3,7 +3,7 @@
// Test user-defined literals.
// Test warning on declaration without leading underscore.
-long double operator"" nounder(long double); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" }
+long double operator ""nounder(long double); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" }
template<char...>
- int operator"" nounder(); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" }
+ int operator ""nounder(); // { dg-warning "literal operator suffixes not preceded by|are reserved for future standardization" }
@@ -3,40 +3,40 @@
// Can't have *both* literal operator template and raw literal operator.
int
-operator"" _abc(const char*)
+operator ""_abc(const char*)
{
return 42;
}
template<char...>
int
- operator"" _abc() // { dg-error "literal operator template|conflicts with raw literal operator" }
+ operator ""_abc() // { dg-error "literal operator template|conflicts with raw literal operator" }
{
return 13;
}
template<char...>
int
- operator"" _def()
+ operator ""_def()
{
return 12;
}
int
-operator"" _def(const char*) // { dg-error "raw literal operator|conflicts with literal operator template" }
+operator ""_def(const char*) // { dg-error "raw literal operator|conflicts with literal operator template" }
{
return 43;
}
int
-operator"" _ghi(long double)
+operator ""_ghi(long double)
{
return 42;
}
template<char...>
int
- operator"" _ghi() // OK
+ operator ""_ghi() // OK
{
return 13;
}
@@ -2,11 +2,11 @@
// { dg-options "-Woverflow" }
// PR c++/52654
int
-operator"" _w(unsigned long long)
+operator ""_w(unsigned long long)
{ return 0; }
int
-operator"" _w(long double)
+operator ""_w(long double)
{ return 0.0L; }
int i = 12345678901234567890123456789012345678901234567890_w;
@@ -2,12 +2,12 @@
// PR c++/52654
int
-operator"" _w(const char*)
+operator ""_w(const char*)
{ return 0; }
template<char...>
int
- operator"" _tw()
+ operator ""_tw()
{ return 0; }
int i = 12345678901234567890123456789012345678901234567890_w;
@@ -1,7 +1,7 @@
// { dg-do compile { target c++11 } }
int
-operator"" _badpreproc(const char *str)
+operator ""_badpreproc(const char *str)
{ return 0; }
#if 123_badpreproc // { dg-error "user-defined literal in preprocessor expression" }
@@ -16,7 +16,7 @@ cstrlen(const char* s)
}
constexpr size_type
-operator "" _lenraw(const char* digits)
+operator ""_lenraw(const char* digits)
{
return cstrlen(digits);
}
@@ -2,7 +2,7 @@
// Make sure handing a string to a raw literal generates a sensible error message.
-int operator"" _embedraw(const char*)
+int operator ""_embedraw(const char*)
{ return 41; }
int k = "Boo!"_embedraw; // { dg-error "unable to find string literal operator" }
@@ -5,7 +5,7 @@
#include <cstring>
int
-operator"" _raw_umber(const char * str)
+operator ""_raw_umber(const char * str)
{
return strlen(str);
}
@@ -3,7 +3,7 @@
#include <string>
-std::string operator"" _i18n(const char*, std::size_t);
+std::string operator ""_i18n(const char*, std::size_t);
std::string vogon_poem = R"V0G0N(
O freddled gruntbuggly thy micturations are to me
@@ -4,21 +4,21 @@
#include <cstdint>
#include <cassert>
-int operator"" _foo(const char*) { return 0; }
-int operator"" _foo(unsigned long long int) { return 1; }
-int operator"" _foo(long double) { return 2; }
-int operator"" _foo(char) { return 3; }
-int operator"" _foo(wchar_t) { return 4; }
-int operator"" _foo(char8_t) { return 5; }
-int operator"" _foo(char16_t) { return 6; }
-int operator"" _foo(char32_t) { return 7; }
-int operator"" _foo(const char*, std::size_t) { return 8; }
-int operator"" _foo(const wchar_t*, std::size_t) { return 9; }
-int operator"" _foo(const char8_t*, std::size_t) { return 10; }
-int operator"" _foo(const char16_t*, std::size_t) { return 11; }
-int operator"" _foo(const char32_t*, std::size_t) { return 12; }
-template<char...> int operator"" _foo2() { return 20; }
-int operator"" _foo2(unsigned long long int) { return 21; }
+int operator ""_foo(const char*) { return 0; }
+int operator ""_foo(unsigned long long int) { return 1; }
+int operator ""_foo(long double) { return 2; }
+int operator ""_foo(char) { return 3; }
+int operator ""_foo(wchar_t) { return 4; }
+int operator ""_foo(char8_t) { return 5; }
+int operator ""_foo(char16_t) { return 6; }
+int operator ""_foo(char32_t) { return 7; }
+int operator ""_foo(const char*, std::size_t) { return 8; }
+int operator ""_foo(const wchar_t*, std::size_t) { return 9; }
+int operator ""_foo(const char8_t*, std::size_t) { return 10; }
+int operator ""_foo(const char16_t*, std::size_t) { return 11; }
+int operator ""_foo(const char32_t*, std::size_t) { return 12; }
+template<char...> int operator ""_foo2() { return 20; }
+int operator ""_foo2(unsigned long long int) { return 21; }
int
main()
@@ -4,19 +4,19 @@
#include <cstdint>
#include <cassert>
-int operator"" _foo(const char*) { return 0; }
-int operator"" _foo(unsigned long long int) { return 1; }
-int operator"" _foo(long double) { return 2; }
-int operator"" _foo(char) { return 3; }
-int operator"" _foo(wchar_t) { return 4; }
-int operator"" _foo(char16_t) { return 5; }
-int operator"" _foo(char32_t) { return 6; }
-int operator"" _foo(const char*, std::size_t) { return 7; }
-int operator"" _foo(const wchar_t*, std::size_t) { return 8; }
-int operator"" _foo(const char16_t*, std::size_t) { return 9; }
-int operator"" _foo(const char32_t*, std::size_t) { return 10; }
-template<char...> int operator"" _foo2() { return 20; }
-int operator"" _foo2(unsigned long long int) { return 21; }
+int operator ""_foo(const char*) { return 0; }
+int operator ""_foo(unsigned long long int) { return 1; }
+int operator ""_foo(long double) { return 2; }
+int operator ""_foo(char) { return 3; }
+int operator ""_foo(wchar_t) { return 4; }
+int operator ""_foo(char16_t) { return 5; }
+int operator ""_foo(char32_t) { return 6; }
+int operator ""_foo(const char*, std::size_t) { return 7; }
+int operator ""_foo(const wchar_t*, std::size_t) { return 8; }
+int operator ""_foo(const char16_t*, std::size_t) { return 9; }
+int operator ""_foo(const char32_t*, std::size_t) { return 10; }
+template<char...> int operator ""_foo2() { return 20; }
+int operator ""_foo2(unsigned long long int) { return 21; }
int
main()
@@ -2,43 +2,43 @@
// Test that the standard suffixes shadow any user-defined suffixes of the same name.
long double
-operator"" L(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" }
+operator ""L(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" }
{ return x; }
unsigned long long int
-operator"" ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
long double
-operator"" l(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" }
+operator ""l(long double x) // { dg-warning "floating-point suffix|shadowed by implementation" }
{ return x; }
unsigned long long int
-operator"" ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
// Namespaces are no hiding place.
@@ -46,43 +46,43 @@ namespace Long
{
long double
-operator"" L(long double x) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""L(long double x) // { dg-warning "integer suffix|shadowed by implementation" }
{ return x; }
unsigned long long int
-operator"" ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""ULL(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
long double
-operator"" l(long double x) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""l(long double x) // { dg-warning "integer suffix|shadowed by implementation" }
{ return x; }
unsigned long long int
-operator"" ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""ull(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""uz(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""zu(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""Z(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""UZ(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
unsigned long long int
-operator"" ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
+operator ""ZU(unsigned long long int k) // { dg-warning "integer suffix|shadowed by implementation" }
{ return k; }
}
@@ -4,33 +4,33 @@
typedef decltype(sizeof(0)) size_type;
constexpr size_type
-operator"" _len(const char*, size_type len)
+operator ""_len(const char*, size_type len)
{
return len;
}
#if __cpp_char8_t
constexpr size_type
-operator"" _len(const char8_t*, size_type len)
+operator ""_len(const char8_t*, size_type len)
{
return len;
}
#endif
constexpr size_type
-operator"" _len(const wchar_t*, size_type len)
+operator ""_len(const wchar_t*, size_type len)
{
return len;
}
constexpr size_type
-operator"" _len(const char16_t*, size_type len)
+operator ""_len(const char16_t*, size_type len)
{
return len;
}
constexpr size_type
-operator"" _len(const char32_t*, size_type len)
+operator ""_len(const char32_t*, size_type len)
{
return len;
}
@@ -3,4 +3,4 @@
#include <string>
-std::string operator"" 5X(const char*, std::size_t); // { dg-error "expected suffix identifier" }
+std::string operator ""5X(const char*, std::size_t); // { dg-error "expected suffix identifier" }
@@ -7,32 +7,32 @@
#include <cassert>
template<char...>
- int operator"" _abc();
+ int operator ""_abc();
template<>
int
- operator"" _abc<>()
+ operator ""_abc<>()
{ return -1; }
template<>
int
- operator"" _abc<'L','U','E'>()
+ operator ""_abc<'L','U','E'>()
{ return 42; }
template<>
int
- operator"" _abc<'6','6','6'>()
+ operator ""_abc<'6','6','6'>()
{ return 21; }
void
test1()
{
- int i = operator"" _abc<'1','2','3'>();
+ int i = operator ""_abc<'1','2','3'>();
assert(i == 45);
- int universal_meaning = operator"" _abc<'L','U','E'>();
+ int universal_meaning = operator ""_abc<'L','U','E'>();
assert(universal_meaning == 42);
- int b = operator"" _abc<'6','6','6'>();
- int z = operator"" _abc<>();
+ int b = operator ""_abc<'6','6','6'>();
+ int z = operator ""_abc<>();
assert(z == -1);
int j = 123_abc;
assert(j == i);
@@ -47,5 +47,5 @@ main()
}
template<char... Chars>
- int operator"" _abc()
+ int operator ""_abc()
{ return 42 + sizeof...(Chars); }
@@ -1,4 +1,4 @@
// { dg-do compile { target c++11 } }
template<char...>
- int operator"" _xyz(unsigned long long); // { dg-error "has invalid argument list" }
+ int operator ""_xyz(unsigned long long); // { dg-error "has invalid argument list" }
@@ -2,6 +2,6 @@
// { dg-do compile { target c++11 } }
template <T, T... U> // { dg-error "'T' has not been declared" }
-int operator"" _foo (); // { dg-error "5:literal operator template .int operator\"\"_foo\\(\\). has invalid parameter list" }
+int operator ""_foo (); // { dg-error "5:literal operator template .int operator\"\"_foo\\(\\). has invalid parameter list" }
template <T... U> // { dg-error "'T' has not been declared" }
-int operator"" _bar (); // { dg-error "5:literal operator template .int operator\"\"_bar\\(\\). has invalid parameter list" }
+int operator ""_bar (); // { dg-error "5:literal operator template .int operator\"\"_bar\\(\\). has invalid parameter list" }
@@ -1,4 +1,4 @@
// { dg-do compile { target c++11 } }
template<char...>
- int operator"" _abc();
+ int operator ""_abc();
@@ -3,10 +3,10 @@
class Foo { };
template<wchar_t...>
- Foo operator"" _Foo(); // { dg-error "7:literal operator template .Foo operator\"\"_Foo\\(\\). has invalid parameter list" }
+ Foo operator ""_Foo(); // { dg-error "7:literal operator template .Foo operator\"\"_Foo\\(\\). has invalid parameter list" }
template<char>
- Foo operator"" _Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" }
+ Foo operator ""_Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" }
template<typename... Type>
- Foo operator"" _Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" }
+ Foo operator ""_Bar(); // { dg-error "7:literal operator template .Foo operator\"\"_Bar\\(\\). has invalid parameter list" }
@@ -3,4 +3,4 @@
class Foo { };
template<char...>
- Foo operator"" _Foo();
+ Foo operator ""_Foo();
@@ -5,4 +5,4 @@
using namespace std::literals::chrono_literals;
-auto blooper = operator"" min(45.0L);
+auto blooper = operator ""min(45.0L);
@@ -6,7 +6,7 @@ struct a {
int c;
};
void d();
-template <char...> constexpr a operator"" _n() { return d; }
+template <char...> constexpr a operator ""_n() { return d; }
struct e;
struct f {
e operator[](int);
@@ -83,21 +83,21 @@ extern "\o{0103}" { int f14 (); } // { dg-error "numeric escape sequence in unev
[[nodiscard ("\x{20}")]] int h19 (); // { dg-error "numeric escape sequence in unevaluated string" }
[[nodiscard ("\h")]] int h20 (); // { dg-error "unknown escape sequence" }
-float operator "" _my0 (const char *);
-float operator "" "" _my1 (const char *);
-float operator L"" _my2 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator u"" _my3 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator U"" _my4 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator u8"" _my5 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator L"" "" _my6 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator u"" "" _my7 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator U"" "" _my8 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator u8"" "" _my9 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator "" L"" _my10 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator "" u"" _my11 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator "" U"" _my12 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator "" u8"" _my13 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
-float operator "\0" _my14 (const char *); // { dg-error "expected empty string after 'operator' keyword" }
-float operator "\x00" _my15 (const char *); // { dg-error "expected empty string after 'operator' keyword" }
-float operator "\h" _my16 (const char *); // { dg-error "expected empty string after 'operator' keyword" }
+float operator ""_my0 (const char *);
+float operator "" ""_my1 (const char *);
+float operator L""_my2 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator u""_my3 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator U""_my4 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator u8""_my5 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator L"" ""_my6 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator u"" ""_my7 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator U"" ""_my8 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator u8"" ""_my9 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator "" L""_my10 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator "" u""_my11 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator "" U""_my12 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator "" u8""_my13 (const char *); // { dg-error "invalid encoding prefix in literal operator" }
+float operator "\0"_my14 (const char *); // { dg-error "expected empty string after 'operator' keyword" }
+float operator "\x00"_my15 (const char *); // { dg-error "expected empty string after 'operator' keyword" }
+float operator "\h"_my16 (const char *); // { dg-error "expected empty string after 'operator' keyword" }
// { dg-error "unknown escape sequence" "" { target *-*-* } .-1 }
@@ -3,7 +3,7 @@
namespace N
{
- int operator"" _X(auto) {} // { dg-error "auto|invalid" }
+ int operator ""_X(auto) {} // { dg-error "auto|invalid" }
}
namespace N {}
@@ -11,7 +11,7 @@ __uint128_t
#else
unsigned long long
#endif
-operator"" _c(const char*) { return 0; }
+operator ""_c(const char*) { return 0; }
constexpr char e() {
long f = true ? 0 : b(long(1));
return b(f);
@@ -11,7 +11,7 @@ struct A {
// auto operator<=> (const A&) = default;
};
-template <A a> constexpr A operator "" _sh() { return a; }
+template <A a> constexpr A operator ""_sh() { return a; }
constexpr auto a = "foo"_sh;
static_assert (a.ar[0] == 'f');
@@ -16,7 +16,7 @@ struct fixed_string {
// Missing deduction guide.
template <fixed_string fs>
-constexpr std::size_t operator"" _udl() {
+constexpr std::size_t operator ""_udl() {
return decltype(fs)::length;
}
@@ -17,4 +17,4 @@ template <typename CharT, std::size_t N>
fixed_string(const CharT (&str)[N]) -> fixed_string<CharT, N>;
template <fixed_string...>
-int operator"" _udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" }
+int operator ""_udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" }
@@ -17,7 +17,7 @@ template <typename CharT, std::size_t N>
fixed_string(const CharT (&str)[N]) -> fixed_string<CharT, N>;
template <fixed_string fs>
-constexpr std::size_t operator"" _udl() {
+constexpr std::size_t operator ""_udl() {
return decltype(fs)::length;
}
@@ -9,4 +9,4 @@ struct literal_class {
};
template <literal_class...>
-int operator"" _udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" }
+int operator ""_udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" }
@@ -10,4 +10,4 @@ struct non_literal_class {
};
template <non_literal_class> // { dg-error "11:is not a valid type for a template non-type parameter because it is not structural" "" { target { ! implicit_constexpr } } }
-int operator"" _udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" "" { target { ! implicit_constexpr } } }
+int operator ""_udl(); // { dg-error "5:literal operator template .int operator\"\"_udl\\(\\). has invalid parameter list" "" { target { ! implicit_constexpr } } }
@@ -9,7 +9,7 @@ struct literal_class {
};
template <literal_class>
-constexpr int operator"" _udl() {
+constexpr int operator ""_udl() {
return 1;
}
@@ -23,7 +23,7 @@ int main()
SA(!__is_convertible(B*, C*));
SA(__is_convertible(A, E));
- using std::operator "" s, std::operator "" sv;
+ using std::operator ""s, std::operator ""sv;
auto stringify = []<typename T>(T x) {
if constexpr (std::is_convertible_v<T, std::string> or
@@ -6,10 +6,10 @@ namespace std {
}
namespace {
- void operator"" _a (const char *, std::size_t) {}
+ void operator ""_a (const char *, std::size_t) {}
}
-void operator"" _a (unsigned long long);
+void operator ""_a (unsigned long long);
template <typename> void f () { ""_a; }
@@ -301,6 +301,9 @@ UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wdeprecated-enum-enum-conve
Wdeprecated-enum-float-conversion
UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wdeprecated-enum-float-conversion)
+Wdeprecated-literal-operator
+UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-Wdeprecated-literal-operator)
+
Wdesignated-init
UrlSuffix(gcc/Warning-Options.html#index-Wdesignated-init)
@@ -2,5 +2,5 @@
#pragma GCC system_header
char
-operator"" stdsuffix(char __c)
+operator ""stdsuffix(char __c)
{ return __c/2; }