r228785 - PR21857: weaken an incorrect assertion.
Richard Smith
richard-llvm at metafoo.co.uk
Tue Feb 10 17:48:48 PST 2015
Author: rsmith
Date: Tue Feb 10 19:48:47 2015
New Revision: 228785
URL: http://llvm.org/viewvc/llvm-project?rev=228785&view=rev
Log:
PR21857: weaken an incorrect assertion.
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/lambda-expressions.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=228785&r1=228784&r2=228785&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Feb 10 19:48:47 2015
@@ -2503,8 +2503,18 @@ Sema::SpecialMemberOverloadResult *Sema:
// will always be a (possibly implicit) declaration to shadow any others.
OverloadCandidateSet OCS(RD->getLocation(), OverloadCandidateSet::CSK_Normal);
DeclContext::lookup_result R = RD->lookup(Name);
- assert(!R.empty() &&
- "lookup for a constructor or assignment operator was empty");
+
+ if (R.empty()) {
+ // We might have no default constructor because we have a lambda's closure
+ // type, rather than because there's some other declared constructor.
+ // Every class has a copy/move constructor, copy/move assignment, and
+ // destructor.
+ assert(SM == CXXDefaultConstructor &&
+ "lookup for a constructor or assignment operator was empty");
+ Result->setMethod(nullptr);
+ Result->setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
+ return Result;
+ }
// Copy the candidates as our processing of them may load new declarations
// from an external source and invalidate lookup_result.
Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=228785&r1=228784&r2=228785&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Tue Feb 10 19:48:47 2015
@@ -437,3 +437,12 @@ namespace error_in_transform_prototype {
f(S()); // expected-note {{requested here}}
}
}
+
+namespace PR21857 {
+ template<typename Fn> struct fun : Fn {
+ fun() = default;
+ using Fn::operator();
+ };
+ template<typename Fn> fun<Fn> wrap(Fn fn);
+ auto x = wrap([](){});
+}
More information about the cfe-commits
mailing list