}
case DeclarationName::CXXLiteralOperatorName:
- return OS << "operator \"\" " << N.getCXXLiteralIdentifier()->getName();
+ return OS << "operator\"\"" << N.getCXXLiteralIdentifier()->getName();
case DeclarationName::CXXConversionFunctionName: {
OS << "operator ";
assert(Args);
if (Args->size() != 1) {
- OS << "operator \"\" " << Node->getUDSuffix()->getName();
+ OS << "operator\"\"" << Node->getUDSuffix()->getName();
TemplateSpecializationType::PrintTemplateArgumentList(
OS, Args->data(), Args->size(), Policy);
OS << "()";
// This isn't a valid literal-operator-id, but we think we know
// what the user meant. Tell them what they should have written.
SmallString<32> Str;
- Str += "\"\" ";
+ Str += "\"\"";
Str += II->getName();
Diag(DiagLoc, DiagId) << FixItHint::CreateReplacement(
SourceRange(TokLocs.front(), TokLocs.back()), Str);
void *a = 123_x; // ok, calls #2
int b = u8"\"ัะตัั ๐"_x; // ok, calls #1
int c = u8R"("ัะตัั ๐)"_x; // ok, calls #1
-int d = "test"_x; // expected-note {{in instantiation of function template specialization 'operator "" _x<char, 't', 'e', 's', 't'>' requested here}}
+int d = "test"_x; // expected-note {{in instantiation of function template specialization 'operator""_x<char, 't', 'e', 's', 't'>' requested here}}
int e = uR"("ัะตัั ๐)"_x;
int f = UR"("ัะตัั ๐)"_x;
-int g = UR"("ัะตัั_๐)"_x; // expected-note {{in instantiation of function template specialization 'operator "" _x<char32_t, 34, 1090, 1077, 1089, 1090, 95, 65536>' requested here}}
+int g = UR"("ัะตัั_๐)"_x; // expected-note {{in instantiation of function template specialization 'operator""_x<char32_t, 34, 1090, 1077, 1089, 1090, 95, 65536>' requested here}}
typedef decltype(sizeof(int)) size_t;
// FIXME: These diagnostics should say 'size_t' instead of 'unsigned long'
-int a = 123_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}}
-int b = 4.2_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'long double' or 'const char *', and no matching literal operator template}}
-int c = "foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}}
-int d = L"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const wchar_t *' and 'unsigned}}
-int e = u8"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}}
-int f = u"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char16_t *' and 'unsigned}}
-int g = U"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char32_t *' and 'unsigned}}
-int h = 'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char'}}
-int i = L'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'wchar_t'}}
-int j = u'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char16_t'}}
-int k = U'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char32_t'}}
+int a = 123_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}}
+int b = 4.2_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'long double' or 'const char *', and no matching literal operator template}}
+int c = "foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char *' and 'unsigned}}
+int d = L"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const wchar_t *' and 'unsigned}}
+int e = u8"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char *' and 'unsigned}}
+int f = u"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char16_t *' and 'unsigned}}
+int g = U"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char32_t *' and 'unsigned}}
+int h = 'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'char'}}
+int i = L'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'wchar_t'}}
+int j = u'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'char16_t'}}
+int k = U'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'char32_t'}}
double &operator "" _x1 (const char *, size_t);
double &i1 = "foo"_x1;
double &i2 = u8"foo"_x1;
-double &i3 = L"foo"_x1; // expected-error {{no matching literal operator for call to 'operator "" _x1' with arguments of types 'const wchar_t *' and 'unsigned long'}}
+double &i3 = L"foo"_x1; // expected-error {{no matching literal operator for call to 'operator""_x1' with arguments of types 'const wchar_t *' and 'unsigned long'}}
char &operator "" _x1(const wchar_t *, size_t);
char &i4 = L"foo"_x1; // ok
std::string operator "" _w(const char16_t*, size_t);
unsigned operator "" _w(const char*);
int main() {
- auto v1 = 1.2_w; // calls operator "" _w(1.2L)
- auto v2 = u"one"_w; // calls operator "" _w(u"one", 3)
- auto v3 = 12_w; // calls operator "" _w("12")
- "two"_w; // expected-error {{no matching literal operator for call to 'operator "" _w' with arguments of types 'const char *' and 'unsigned long'}}
+ auto v1 = 1.2_w; // calls operator""_w(1.2L)
+ auto v2 = u"one"_w; // calls operator""_w(u"one", 3)
+ auto v3 = 12_w; // calls operator""_w("12")
+ "two"_w; // expected-error {{no matching literal operator for call to 'operator""_w' with arguments of types 'const char *' and 'unsigned long'}}
same_type<decltype(v1), long double> test1;
same_type<decltype(v2), std::string> test2;
namespace rdar13605348 {
class C {
- double operator"" _x(long double value) { return double(value); } // expected-error{{literal operator 'operator "" _x' must be in a namespace or global scope}}
+ double operator"" _x(long double value) { return double(value); } // expected-error{{literal operator 'operator""_x' must be in a namespace or global scope}}
double value() { return 3.2_x; } // expected-error{{no matching literal operator for call to}}
};
double i = 0p+3; // expected-error{{invalid suffix 'p' on integer constant}}
#define PREFIX(x) foo ## x
double foo0p = 1, j = PREFIX(0p+3); // ok
-double k = 0x42_amp+3; // expected-error-re{{{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator "" _amp'}}}}
+double k = 0x42_amp+3; // expected-error-re{{{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator""_amp'}}}}
erk
flux
)x" "eep\x1f"\
-_no_such_suffix // expected-error {{'operator "" _no_such_suffix'}}
+_no_such_suffix // expected-error {{'operator""_no_such_suffix'}}
"and a bit more"
"and another suffix"_no_such_suffix;
char c =
'\x14'\
-_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+_no_such_suffix; // expected-error {{'operator""_no_such_suffix'}}
int &r =
1234567\
-_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+_no_such_suffix; // expected-error {{'operator""_no_such_suffix'}}
int k =
1234567.89\
-_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+_no_such_suffix; // expected-error {{'operator""_no_such_suffix'}}
// Make sure we handle more interesting ways of writing a string literal which
// is "" in translation phase 7.
// Make sure we treat UCNs and UTF-8 as equivalent.
int operator""_ยตs(unsigned long long) {} // expected-note {{previous}}
int hundred_ยตs = 50_ยตs + 50_\u00b5s;
-int operator""_\u00b5s(unsigned long long) {} // expected-error {{redefinition of 'operator "" _ยตs'}}
+int operator""_\u00b5s(unsigned long long) {} // expected-error {{redefinition of 'operator""_ยตs'}}
int operator""_\U0000212B(long double) {} // expected-note {{previous}}
int hundred_โซ = 50.0_โซ + 50._\U0000212B;
-int operator""_โซ(long double) {} // expected-error {{redefinition of 'operator "" _โซ'}}
+int operator""_โซ(long double) {} // expected-error {{redefinition of 'operator""_โซ'}}
int operator""_๐(char) {} // expected-note {{previous}}
int ๐ = '4'_๐ + '2'_\U00010000;
-int operator""_\U00010000(char) {} // expected-error {{redefinition of 'operator "" _๐'}}
+int operator""_\U00010000(char) {} // expected-error {{redefinition of 'operator""_๐'}}
// These all declare the same function.
int operator""_โฎ""_\u212e""_\U0000212e""(const char*, size_t);
// RUN: %clang_cc1 -std=c++11 -ast-print %s | FileCheck %s
-// CHECK: auto operator "" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
+// CHECK: auto operator""_foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
auto operator"" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
-// CHECK: decltype(""_foo) operator "" _bar(unsigned long long);
+// CHECK: decltype(""_foo) operator""_bar(unsigned long long);
decltype(""_foo) operator"" _bar(unsigned long long);
-// CHECK: decltype(42_bar) operator "" _baz(long double);
+// CHECK: decltype(42_bar) operator""_baz(long double);
decltype(42_bar) operator"" _baz(long double);
-// CHECK: decltype(4.5_baz) operator "" _baz(char);
+// CHECK: decltype(4.5_baz) operator""_baz(char);
decltype(4.5_baz) operator"" _baz(char);
-// CHECK: const char *operator "" _quux(const char *);
+// CHECK: const char *operator""_quux(const char *);
const char *operator"" _quux(const char *);
-// CHECK: template <char ...> const char *operator "" _fritz();
+// CHECK: template <char ...> const char *operator""_fritz();
template<char...> const char *operator"" _fritz();
// CHECK: const char *p1 = "bar1"_foo;
const char *p10 = 3.300e+15_fritz;
template <class C, C...> const char *operator"" _suffix();
-// CHECK: const char *PR23120 = operator "" _suffix<char32_t, 66615>();
+// CHECK: const char *PR23120 = operator""_suffix<char32_t, 66615>();
const char *PR23120 = U"๐ท"_suffix;
// CHECK: ;
namespace M {
int operator"" _using(char);
}
- int k1 = 'x'_using; // expected-error {{no matching literal operator for call to 'operator "" _using'}}
+ int k1 = 'x'_using; // expected-error {{no matching literal operator for call to 'operator""_using'}}
using M::operator "" _using;
int k2 = 'x'_using;
int operator"" _ambig1(const char *); // expected-note {{candidate}}
template<char...> int operator"" _ambig1(); // expected-note {{candidate}}
- int k1 = 123_ambig1; // expected-error {{call to 'operator "" _ambig1' is ambiguous}}
+ int k1 = 123_ambig1; // expected-error {{call to 'operator""_ambig1' is ambiguous}}
namespace Inner {
template<char...> int operator"" _ambig2(); // expected-note 3{{candidate}}
int operator"" _ambig2(const char *); // expected-note 3{{candidate}}
using Inner::operator"" _ambig2;
- int k2 = 123_ambig2; // expected-error {{call to 'operator "" _ambig2' is ambiguous}}
+ int k2 = 123_ambig2; // expected-error {{call to 'operator""_ambig2' is ambiguous}}
namespace N {
using Inner::operator"" _ambig2;
int k = _x(); // expected-error {{undeclared identifier '_x'}}
int _y(unsigned long long);
- int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator "" _y'}}
+ int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator""_y'}}
}
namespace PR14950 {
template<...> // expected-error {{expected template parameter}}
int operator"" _b(); // expected-error {{no function template matches function template specialization}}
- int main() { return 0_b; } // expected-error {{no matching literal operator for call to 'operator "" _b'}}
+ int main() { return 0_b; } // expected-error {{no matching literal operator for call to 'operator""_b'}}
}
namespace bad_names {
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
#include <stddef.h>
struct tag {
- void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator "" _tag_bad' must be in a namespace or global scope}}
+ void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator""_tag_bad' must be in a namespace or global scope}}
friend void operator "" _tag_good (const char *);
};
void operator "" _good (c*);
// Check extra cv-qualifiers
-void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator "" _cv_good' is not valid}}
+void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator""_cv_good' is not valid}}
// Template declaration
template <char...> void operator "" _good ();
// FIXME: Test some invalid decls that might crop up.
-template <typename...> void operator "" _invalid(); // expected-error {{parameter declaration for literal operator 'operator "" _invalid' is not valid}}
+template <typename...> void operator "" _invalid(); // expected-error {{parameter declaration for literal operator 'operator""_invalid' is not valid}}
+
+_Complex float operator""if(long double); // expected-warning {{reserved}}
+_Complex float test_if_1() { return 2.0f + 1.5if; };
+void test_if_2() { "foo"if; } // expected-error {{no matching literal operator for call to 'operator""if'}}