[PATCH] D22609: Suppress reserved user defined literal warning within namespace std.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 20 21:15:13 PDT 2016


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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22609.64816.patch
Type: text/x-patch
Size: 1162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160721/9891c7b1/attachment.bin>


More information about the cfe-commits mailing list