summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2017-02-15 20:49:39 +0000
committerHans Wennborg <hans@hanshq.net>2017-02-15 20:49:39 +0000
commit155bc5fa0d90f001ac6d4242b72fddd9d6017f71 (patch)
treeb37ea6ee99c10857bcbb0a92585c4f397a6ceef9
parent77a08a4030acb0db81ed9bc123792ef54db75088 (diff)
Merging r295149:
------------------------------------------------------------------------ r295149 | rsmith | 2017-02-14 20:18:23 -0800 (Tue, 14 Feb 2017) | 2 lines Fix assertion failure due to implicit special member lookup lacking a source location. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_40@295233 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaLookup.cpp11
-rw-r--r--test/SemaCXX/cxx11-inheriting-ctors.cpp28
2 files changed, 35 insertions, 4 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 38a7b8c127..e2cb2c8169 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -2831,6 +2831,9 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD,
assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
"parameter-less special members can't have qualified arguments");
+ // FIXME: Get the caller to pass in a location for the lookup.
+ SourceLocation LookupLoc = RD->getLocation();
+
llvm::FoldingSetNodeID ID;
ID.AddPointer(RD);
ID.AddInteger(SM);
@@ -2912,7 +2915,7 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD,
VK = VK_RValue;
}
- OpaqueValueExpr FakeArg(SourceLocation(), ArgType, VK);
+ OpaqueValueExpr FakeArg(LookupLoc, ArgType, VK);
if (SM != CXXDefaultConstructor) {
NumArgs = 1;
@@ -2926,13 +2929,13 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD,
if (VolatileThis)
ThisTy.addVolatile();
Expr::Classification Classification =
- OpaqueValueExpr(SourceLocation(), ThisTy,
+ OpaqueValueExpr(LookupLoc, ThisTy,
RValueThis ? VK_RValue : VK_LValue).Classify(Context);
// Now we perform lookup on the name we computed earlier and do overload
// resolution. Lookup is only performed directly into the class since there
// will always be a (possibly implicit) declaration to shadow any others.
- OverloadCandidateSet OCS(RD->getLocation(), OverloadCandidateSet::CSK_Normal);
+ OverloadCandidateSet OCS(LookupLoc, OverloadCandidateSet::CSK_Normal);
DeclContext::lookup_result R = RD->lookup(Name);
if (R.empty()) {
@@ -2987,7 +2990,7 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD,
}
OverloadCandidateSet::iterator Best;
- switch (OCS.BestViableFunction(*this, SourceLocation(), Best)) {
+ switch (OCS.BestViableFunction(*this, LookupLoc, Best)) {
case OR_Success:
Result->setMethod(cast<CXXMethodDecl>(Best->Function));
Result->setKind(SpecialMemberOverloadResult::Success);
diff --git a/test/SemaCXX/cxx11-inheriting-ctors.cpp b/test/SemaCXX/cxx11-inheriting-ctors.cpp
index c9e01188fd..7d6f4f09f0 100644
--- a/test/SemaCXX/cxx11-inheriting-ctors.cpp
+++ b/test/SemaCXX/cxx11-inheriting-ctors.cpp
@@ -105,3 +105,31 @@ namespace PR31606 {
// Note, we do *not* allow operator=='s argument to use the inherited A::A(Base&&) constructor to construct from B{}.
bool b = A{} == B{}; // expected-error {{invalid operands}}
}
+
+namespace implicit_member_srcloc {
+ template<class T>
+ struct S3 {
+ };
+
+ template<class T>
+ struct S2 {
+ S2(S3<T> &&);
+ };
+
+ template<class T>
+ struct S1 : S2<T> {
+ using S2<T>::S2;
+ S1();
+ };
+
+ template<class T>
+ struct S0 {
+ S0();
+ S0(S0&&) = default;
+ S1<T> m1;
+ };
+
+ void foo1() {
+ S0<int> s0;
+ }
+}