PR21857: weaken an incorrect assertion.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Feb 2015 01:48:47 +0000 (01:48 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Feb 2015 01:48:47 +0000 (01:48 +0000)
llvm-svn: 228785

clang/lib/Sema/SemaLookup.cpp
clang/test/SemaCXX/lambda-expressions.cpp

index 9184a9f..65e8ffb 100644 (file)
@@ -2503,8 +2503,18 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD,
   // 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.
index cad322a..7911c1b 100644 (file)
@@ -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([](){});
+}