EricWF created this revision. EricWF added reviewers: rsmith, majnemer. EricWF added a subscriber: cfe-commits.
Currently Clang warns if a UDL is defined with a name reserved for future standardization. This patch suppresses the diagnostic within namespace std. https://reviews.llvm.org/D22609 Files: lib/Sema/SemaDeclCXX.cpp test/CXX/lex/lex.literal/lex.ext/p10.cpp Index: test/CXX/lex/lex.literal/lex.ext/p10.cpp =================================================================== --- test/CXX/lex/lex.literal/lex.ext/p10.cpp +++ test/CXX/lex/lex.literal/lex.ext/p10.cpp @@ -12,3 +12,7 @@ const char *p = ""wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} const char *q = R"x("hello")x"wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} } + +namespace std { + void operator "" stdwibble(const char*); +} Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -12101,7 +12101,7 @@ StringRef LiteralName = FnDecl->getDeclName().getCXXLiteralIdentifier()->getName(); - if (LiteralName[0] != '_') { + if (LiteralName[0] != '_' && !FnDecl->isInStdNamespace()) { // C++11 [usrlit.suffix]p1: // Literal suffix identifiers that do not start with an underscore // are reserved for future standardization.
Index: test/CXX/lex/lex.literal/lex.ext/p10.cpp =================================================================== --- test/CXX/lex/lex.literal/lex.ext/p10.cpp +++ test/CXX/lex/lex.literal/lex.ext/p10.cpp @@ -12,3 +12,7 @@ const char *p = ""wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} const char *q = R"x("hello")x"wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} } + +namespace std { + void operator "" stdwibble(const char*); +} Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -12101,7 +12101,7 @@ StringRef LiteralName = FnDecl->getDeclName().getCXXLiteralIdentifier()->getName(); - if (LiteralName[0] != '_') { + if (LiteralName[0] != '_' && !FnDecl->isInStdNamespace()) { // C++11 [usrlit.suffix]p1: // Literal suffix identifiers that do not start with an underscore // are reserved for future standardization.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits