forked from OSchip/llvm-project
Don't see through 'using member-declarations' when determining the relation of any potential implicit object expression to the parent class of the member function containing the function call.
Prior to this patch clang would not error here: template <class T> struct B; template <class T> struct A { void foo(); void foo2(); void test1() { B<T>::foo(); // OK, foo is declared in A<int> - matches type of 'this'. B<T>::foo2(); // This should be an error! // foo2 is found in B<int>, 'base unrelated' to 'this'. } }; template <class T> struct B : A<T> { using A<T>::foo2; }; llvm-svn: 311851
This commit is contained in:
parent
17ee7c0977
commit
5f5b29dd22
|
@ -102,15 +102,15 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef,
|
|||
bool hasNonInstance = false;
|
||||
bool isField = false;
|
||||
BaseSet Classes;
|
||||
for (NamedDecl *D : R) {
|
||||
// Look through any using decls.
|
||||
D = D->getUnderlyingDecl();
|
||||
|
||||
for (const NamedDecl *const D : R) {
|
||||
if (D->isCXXInstanceMember()) {
|
||||
isField |= isa<FieldDecl>(D) || isa<MSPropertyDecl>(D) ||
|
||||
isa<IndirectFieldDecl>(D);
|
||||
// Look through any using decls.
|
||||
const NamedDecl *const UnderlyingDecl = D->getUnderlyingDecl();
|
||||
isField |= isa<FieldDecl>(UnderlyingDecl) ||
|
||||
isa<MSPropertyDecl>(UnderlyingDecl) ||
|
||||
isa<IndirectFieldDecl>(UnderlyingDecl);
|
||||
|
||||
CXXRecordDecl *R = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
const CXXRecordDecl *R = cast<CXXRecordDecl>(D->getDeclContext());
|
||||
Classes.insert(R->getCanonicalDecl());
|
||||
} else
|
||||
hasNonInstance = true;
|
||||
|
|
|
@ -64,17 +64,26 @@ namespace test2 {
|
|||
|
||||
template <class T> struct A {
|
||||
void foo();
|
||||
|
||||
void foo2();
|
||||
static void static_foo();
|
||||
static void static_foo2();
|
||||
|
||||
void test0() {
|
||||
Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}}
|
||||
}
|
||||
|
||||
void test1() {
|
||||
B<T>::foo();
|
||||
B<T>::foo2(); // expected-error {{call to non-static member function without an object argument}}
|
||||
B<T>::static_foo();
|
||||
B<T>::static_foo2();
|
||||
}
|
||||
|
||||
static void test2() {
|
||||
B<T>::foo(); // expected-error {{call to non-static member function without an object argument}}
|
||||
B<T>::foo2(); // expected-error {{call to non-static member function without an object argument}}
|
||||
B<T>::static_foo();
|
||||
B<T>::static_foo2();
|
||||
}
|
||||
|
||||
void test3() {
|
||||
|
@ -83,15 +92,17 @@ namespace test2 {
|
|||
};
|
||||
|
||||
template <class T> struct B : A<T> {
|
||||
using A<T>::foo2;
|
||||
using A<T>::static_foo2;
|
||||
};
|
||||
|
||||
|
||||
template <class T> struct C {
|
||||
};
|
||||
|
||||
int test() {
|
||||
A<int> a;
|
||||
a.test0(); // no instantiation note here, decl is ill-formed
|
||||
a.test1();
|
||||
a.test1(); // expected-note {{in instantiation}}
|
||||
a.test2(); // expected-note {{in instantiation}}
|
||||
a.test3(); // expected-note {{in instantiation}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue