diff options
author | Faisal Vali <faisalv@yahoo.com> | 2017-08-27 16:49:47 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2017-08-27 16:49:47 +0000 |
commit | 462390a3e04b364783b941b95bdecf36318fef01 (patch) | |
tree | d800470e20bcf989af75c7e5743548010cde0185 /test/CXX | |
parent | 68076440bfe96db15eafda7e05e32385f6f5c4b8 (diff) |
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;
};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r-- | test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp index 9116e7146f..a6092f5b90 100644 --- a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp +++ b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp @@ -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}} } |