Commit dff88e09 authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r293678:

------------------------------------------------------------------------
r293678 | ahatanak | 2017-01-31 11:53:32 -0800 (Tue, 31 Jan 2017) | 9 lines

[Sema] Transform a templated name before looking it up in
FindInstantiatedDecl or passing it to RebuildMemberExpr.

This fixes PR30361.

rdar://problem/17341274

Differential Revision: https://reviews.llvm.org/D24969

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_40@293782 91177308-0d34-0410-b5e6-96231b3b80d8
parent 5114b5eb
......@@ -4996,8 +4996,12 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
NamedDecl *Result = nullptr;
// FIXME: If the name is a dependent name, this lookup won't necessarily
// find it. Does that ever matter?
if (D->getDeclName()) {
DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
if (auto Name = D->getDeclName()) {
DeclarationNameInfo NameInfo(Name, D->getLocation());
Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
if (!Name)
return nullptr;
DeclContext::lookup_result Found = ParentDC->lookup(Name);
Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
} else {
// Since we don't have a name for the entity we're looking for,
......
......@@ -8818,12 +8818,18 @@ TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
// base (and therefore couldn't do the check) and a
// nested-name-qualifier (and therefore could do the lookup).
NamedDecl *FirstQualifierInScope = nullptr;
DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
if (MemberNameInfo.getName()) {
MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
if (!MemberNameInfo.getName())
return ExprError();
}
return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
E->isArrow(),
QualifierLoc,
TemplateKWLoc,
E->getMemberNameInfo(),
MemberNameInfo,
Member,
FoundDecl,
(E->hasExplicitTemplateArgs()
......
......@@ -431,3 +431,23 @@ class Invalid {
// The constructor definition should not have errors
Invalid::~Invalid() {}
namespace PR30361 {
template <typename T>
struct C1 {
~C1() {}
operator C1<T>* () { return nullptr; }
void foo1();
};
template<typename T>
void C1<T>::foo1() {
C1::operator C1<T>*();
C1::~C1();
}
void foo1() {
C1<int> x;
x.foo1();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment