r179150 - <rdar://problem/13605348> Don't consider invalid user-defined literal operators during overload resolution.
Douglas Gregor
dgregor at apple.com
Tue Apr 9 22:18:00 PDT 2013
Author: dgregor
Date: Wed Apr 10 00:18:00 2013
New Revision: 179150
URL: http://llvm.org/viewvc/llvm-project?rev=179150&view=rev
Log:
<rdar://problem/13605348> Don't consider invalid user-defined literal operators during overload resolution.
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/CXX/over/over.oper/over.literal/p2.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=179150&r1=179149&r2=179150&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Apr 10 00:18:00 2013
@@ -2582,6 +2582,12 @@ Sema::LookupLiteralOperator(Scope *S, Lo
bool IsRaw = false;
bool IsExactMatch = false;
+ // If the declaration we found is invalid, skip it.
+ if (D->isInvalidDecl()) {
+ F.erase();
+ continue;
+ }
+
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (FD->getNumParams() == 1 &&
FD->getParamDecl(0)->getType()->getAs<PointerType>())
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=179150&r1=179149&r2=179150&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 Wed Apr 10 00:18:00 2013
@@ -33,3 +33,12 @@ template<char...> void operator "" _h()
template<> void operator "" _h<'a', 'b', 'c'>() {}
template void operator "" _h<'a', 'b', 'c', 'd'>();
+
+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 value() { return 3.2_x; } // expected-error{{no matching literal operator for call to}}
+};
+
+}
More information about the cfe-commits
mailing list