diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-12-12 03:40:18 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-12-12 03:40:18 +0000 |
commit | db05cd37a1e75fbdb9775f1b152e6546b94634e8 (patch) | |
tree | fa76bc7a46322b03a5d5cd04ad6005eeb1d38e5b /clang/test/SemaCXX/member-pointer.cpp | |
parent | 4b739894f0351c6b9c2b453ab6284e93920e39f8 (diff) | |
download | bcm5719-llvm-db05cd37a1e75fbdb9775f1b152e6546b94634e8.tar.gz bcm5719-llvm-db05cd37a1e75fbdb9775f1b152e6546b94634e8.zip |
PR17602: check accessibility when performing an implicit derived-to-base
conversion on the LHS of a .* or ->*. Slightly improve diagnostics in case
of an ambiguous base class.
llvm-svn: 197125
Diffstat (limited to 'clang/test/SemaCXX/member-pointer.cpp')
-rw-r--r-- | clang/test/SemaCXX/member-pointer.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp index 4e8b4a813ba..82873d9c7da 100644 --- a/clang/test/SemaCXX/member-pointer.cpp +++ b/clang/test/SemaCXX/member-pointer.cpp @@ -7,6 +7,7 @@ struct D : A {}; struct E : A {}; struct F : D, E {}; struct G : virtual D {}; +class H : A {}; // expected-note 2{{implicitly declared private here}} int A::*pdi1; int (::A::*pdi2); @@ -115,8 +116,11 @@ void h() { (void)(d.*pai); (void)(pd->*pai); F f, *ptrf = &f; - (void)(f.*pai); // expected-error {{left hand operand to .* must be a class compatible with the right hand operand, but is 'F'}} - (void)(ptrf->*pai); // expected-error {{left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'F *'}} + (void)(f.*pai); // expected-error {{ambiguous conversion from derived class 'F' to base class 'A'}} + (void)(ptrf->*pai); // expected-error {{ambiguous conversion from derived class 'F' to base class 'A'}} + H h, *ptrh = &h; + (void)(h.*pai); // expected-error {{cannot cast 'H' to its private base class 'A'}} + (void)(ptrh->*pai); // expected-error {{cannot cast 'H' to its private base class 'A'}} (void)(hm.*i); // expected-error {{pointer-to-member}} (void)(phm->*i); // expected-error {{pointer-to-member}} |