diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-15 04:18:23 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-15 04:18:23 +0000 |
| commit | 171e4b545df5cedf8f631e6724a93cf90d42502c (patch) | |
| tree | 54b377c293abf9630d2e87361608fb5185096d7f /clang | |
| parent | 96e36a67ed98340da023595dfc173340d74ecfbb (diff) | |
| download | bcm5719-llvm-171e4b545df5cedf8f631e6724a93cf90d42502c.tar.gz bcm5719-llvm-171e4b545df5cedf8f631e6724a93cf90d42502c.zip | |
Fix assertion failure due to implicit special member lookup lacking a source location.
llvm-svn: 295149
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 11 | ||||
| -rw-r--r-- | clang/test/SemaCXX/cxx11-inheriting-ctors.cpp | 28 |
2 files changed, 35 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 9ea433ffe5c..ab03e689e2c 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2838,6 +2838,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); @@ -2919,7 +2922,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; @@ -2933,13 +2936,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()) { @@ -2994,7 +2997,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/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp b/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp index c9e01188fd2..7d6f4f09f09 100644 --- a/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp +++ b/clang/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; + } +} |

