forked from OSchip/llvm-project
Within a template, qualified name lookup can refer to a non-dependent type
that is not known to be a base class at template definition time due to some dependent base class. Treat qualified name lookup that refers to a non-static data member or function as implicit class member access when the "this" type would be dependent. llvm-svn: 85718
This commit is contained in:
parent
291f6145b8
commit
5897e097a6
|
@ -2395,6 +2395,12 @@ bool Sema::isImplicitMemberReference(const CXXScopeSpec *SS, NamedDecl *D,
|
||||||
// Determine whether the declaration(s) we found are actually in a base
|
// Determine whether the declaration(s) we found are actually in a base
|
||||||
// class. If not, this isn't an implicit member reference.
|
// class. If not, this isn't an implicit member reference.
|
||||||
ThisType = MD->getThisType(Context);
|
ThisType = MD->getThisType(Context);
|
||||||
|
|
||||||
|
// If the type of "this" is dependent, we can't tell if the member is in a
|
||||||
|
// base class or not, so treat this as a dependent implicit member reference.
|
||||||
|
if (ThisType->isDependentType())
|
||||||
|
return true;
|
||||||
|
|
||||||
QualType CtxType = Context.getTypeDeclType(cast<CXXRecordDecl>(Ctx));
|
QualType CtxType = Context.getTypeDeclType(cast<CXXRecordDecl>(Ctx));
|
||||||
QualType ClassType
|
QualType ClassType
|
||||||
= Context.getTypeDeclType(cast<CXXRecordDecl>(MD->getParent()));
|
= Context.getTypeDeclType(cast<CXXRecordDecl>(MD->getParent()));
|
||||||
|
|
|
@ -81,3 +81,20 @@ int *a(A0<int> &x0, A1<int> &x1) {
|
||||||
int *y0 = x0;
|
int *y0 = x0;
|
||||||
int *y1 = x1; // expected-error{{initializing}}
|
int *y1 = x1; // expected-error{{initializing}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct X0Base {
|
||||||
|
int &f();
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct X0 : X0Base {
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename U>
|
||||||
|
struct X1 : X0<U> {
|
||||||
|
int &f2() { return X0Base::f(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
void test_X1(X1<int> x1i) {
|
||||||
|
int &ir = x1i.f2();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue