[cfe-commits] r152395 - in /cfe/trunk: lib/AST/DeclarationName.cpp test/CXX/over/over.oper/over.literal/p2.cpp test/SemaCXX/cxx11-user-defined-literals.cpp

Richard Smith richard-llvm at metafoo.co.uk
Fri Mar 9 00:37:16 PST 2012


Author: rsmith
Date: Fri Mar  9 02:37:16 2012
New Revision: 152395

URL: http://llvm.org/viewvc/llvm-project?rev=152395&view=rev
Log:
Literal operator suffixes and regular names live in separate namespaces.

Modified:
    cfe/trunk/lib/AST/DeclarationName.cpp
    cfe/trunk/test/CXX/over/over.oper/over.literal/p2.cpp
    cfe/trunk/test/SemaCXX/cxx11-user-defined-literals.cpp

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=152395&r1=152394&r2=152395&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Fri Mar  9 02:37:16 2012
@@ -53,7 +53,7 @@
   void *FETokenInfo;
 };
 
-/// CXXLiberalOperatorName - Contains the actual identifier that makes up the
+/// CXXLiteralOperatorName - Contains the actual identifier that makes up the
 /// name.
 ///
 /// This identifier is stored here rather than directly in DeclarationName so as
@@ -64,6 +64,10 @@
 public:
   IdentifierInfo *ID;
 
+  /// FETokenInfo - Extra information associated with this operator
+  /// name that can be used by the front end.
+  void *FETokenInfo;
+
   void Profile(llvm::FoldingSetNodeID &FSID) {
     FSID.AddPointer(ID);
   }
@@ -333,7 +337,7 @@
     return getAsCXXOperatorIdName()->FETokenInfo;
 
   case CXXLiteralOperatorName:
-    return getCXXLiteralIdentifier()->getFETokenInfo<void>();
+    return getAsCXXLiteralOperatorIdName()->FETokenInfo;
 
   default:
     llvm_unreachable("Declaration name has no FETokenInfo");
@@ -357,7 +361,7 @@
     break;
 
   case CXXLiteralOperatorName:
-    getCXXLiteralIdentifier()->setFETokenInfo(T);
+    getAsCXXLiteralOperatorIdName()->FETokenInfo = T;
     break;
 
   default:
@@ -471,6 +475,7 @@
   CXXLiteralOperatorIdName *LiteralName = new (Ctx) CXXLiteralOperatorIdName;
   LiteralName->ExtraKindOrNumArgs = DeclarationNameExtra::CXXLiteralOperator;
   LiteralName->ID = II;
+  LiteralName->FETokenInfo = 0;
 
   LiteralNames->InsertNode(LiteralName, InsertPos);
   return DeclarationName(LiteralName);

Modified: cfe/trunk/test/CXX/over/over.oper/over.literal/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/over/over.oper/over.literal/p2.cpp?rev=152395&r1=152394&r2=152395&view=diff
==============================================================================
--- cfe/trunk/test/CXX/over/over.oper/over.literal/p2.cpp (original)
+++ cfe/trunk/test/CXX/over/over.oper/over.literal/p2.cpp Fri Mar  9 02:37:16 2012
@@ -25,3 +25,9 @@
 extern "C++" {
   void operator "" _g(const char *);
 }
+
+template<char...> void operator "" _h() {}
+
+template<> void operator "" _h<'a', 'b', 'c'>() {}
+
+template void operator "" _h<'a', 'b', 'c', 'd'>();

Modified: cfe/trunk/test/SemaCXX/cxx11-user-defined-literals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-user-defined-literals.cpp?rev=152395&r1=152394&r2=152395&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-user-defined-literals.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx11-user-defined-literals.cpp Fri Mar  9 02:37:16 2012
@@ -126,3 +126,12 @@
 }
 static_assert(0x1234_hash == 0x103eff5e, "");
 static_assert(hash<'0', 'x', '1', '2', '3', '4'>(0) == 0x103eff5e, "");
+
+// Functions and literal suffixes go in separate namespaces.
+namespace Namespace {
+  template<char...> int operator"" _x();
+  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'}}
+}





More information about the cfe-commits mailing list