[cfe-commits] r152509 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/over/over.oper/over.literal/p2.cpp test/SemaCXX/literal-operators.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Sat Mar 10 14:18:57 PST 2012
Author: rsmith
Date: Sat Mar 10 16:18:57 2012
New Revision: 152509
URL: http://llvm.org/viewvc/llvm-project?rev=152509&view=rev
Log:
PR12225: The requirement that literal operators be namespace-scope functions
does not imply that such functions can't be declared at block scope.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/over/over.oper/over.literal/p2.cpp
cfe/trunk/test/SemaCXX/literal-operators.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=152509&r1=152508&r2=152509&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Mar 10 16:18:57 2012
@@ -9309,10 +9309,7 @@
/// of this literal operator function is well-formed. If so, returns
/// false; otherwise, emits appropriate diagnostics and returns true.
bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) {
- DeclContext *DC = FnDecl->getDeclContext();
- Decl::Kind Kind = DC->getDeclKind();
- if (Kind != Decl::TranslationUnit && Kind != Decl::Namespace &&
- Kind != Decl::LinkageSpec) {
+ if (isa<CXXMethodDecl>(FnDecl)) {
Diag(FnDecl->getLocation(), diag::err_literal_operator_outside_namespace)
<< FnDecl->getDeclName();
return true;
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=152509&r1=152508&r2=152509&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 Sat Mar 10 16:18:57 2012
@@ -13,6 +13,8 @@
class C {
void operator "" _c(const char *); // expected-error {{must be in a namespace or global scope}}
+ static void operator "" _c(unsigned long long); // expected-error {{must be in a namespace or global scope}}
+
friend void operator "" _d(const char *);
};
Modified: cfe/trunk/test/SemaCXX/literal-operators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/literal-operators.cpp?rev=152509&r1=152508&r2=152509&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/literal-operators.cpp (original)
+++ cfe/trunk/test/SemaCXX/literal-operators.cpp Sat Mar 10 16:18:57 2012
@@ -13,7 +13,7 @@
extern "C++" void operator "" _extern_good (const char *);
extern "C++" { void operator "" _extern_good (const char *); }
-void fn () { void operator "" _fn_bad (const char *); } // expected-error {{literal operator 'operator "" _fn_bad' must be in a namespace or global scope}}
+void fn () { void operator "" _fn_good (const char *); }
// One-param declarations (const char * was already checked)
void operator "" _good (char);
More information about the cfe-commits
mailing list