Richard Smith | 0576681 | 2012-08-18 00:55:03 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-comparison %s |
Douglas Gregor | dd8c10f | 2010-10-22 17:36:51 +0000 | [diff] [blame] | 2 | |
| 3 | // PR8439 |
| 4 | class A |
| 5 | { |
| 6 | }; |
| 7 | |
| 8 | class B |
| 9 | { |
| 10 | public: |
| 11 | A & m; |
| 12 | }; |
| 13 | |
| 14 | class Base |
| 15 | { |
| 16 | public: |
| 17 | B &f(); |
| 18 | }; |
| 19 | |
| 20 | class Derived1 : public Base { }; |
| 21 | |
| 22 | class Derived2 : public Base { }; |
| 23 | |
| 24 | class X : public B, public Derived2, public Derived1 |
| 25 | { |
| 26 | public: |
| 27 | virtual void g(); |
| 28 | }; |
| 29 | |
| 30 | void X::g() |
| 31 | { |
| 32 | m.f<int>(); // expected-error{{no member named 'f' in 'A'}} \ |
| 33 | // expected-error{{expected '(' for function-style cast}} \ |
| 34 | // expected-error{{expected expression}} |
| 35 | } |
Douglas Gregor | 95e5510 | 2011-10-21 15:47:52 +0000 | [diff] [blame] | 36 | |
| 37 | namespace PR11134 { |
| 38 | template<typename Derived> class A; |
| 39 | template<typename Derived> class B : A<Derived> { |
| 40 | typedef A<Derived> Base; |
| 41 | using Base::member; |
| 42 | int member; |
| 43 | }; |
| 44 | } |
| 45 | |
Richard Smith | 0576681 | 2012-08-18 00:55:03 +0000 | [diff] [blame] | 46 | namespace AddrOfMember { |
| 47 | struct A { int X; }; |
| 48 | typedef int (A::*P); |
| 49 | template<typename T> struct S : T { |
| 50 | void f() { |
| 51 | P(&T::X) // expected-error {{cannot cast from type 'int *' to member pointer type 'P'}} |
| 52 | == &A::X; |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | void g() { |
| 57 | S<A>().f(); // ok, &T::X is 'int (A::*)', not 'int *', even though T is a base class |
| 58 | } |
| 59 | |
| 60 | struct B : A { static int X; }; |
| 61 | void h() { |
| 62 | S<B>().f(); // expected-note {{here}} |
| 63 | } |
| 64 | } |