// RUN: clang-cc -fsyntax-only -verify %s 
namespace A
{
    namespace B
    {
        struct base
        {
            void x() {}
            void y() {}
        };
    }

	struct whatever
	{
		void foo();
	};

    struct sub : B::base
    {
        void x() {}
		whatever * operator->() { return 0; }
    };
}

struct bad {
	int x();
};

namespace C
{
    void fun()
    {
        A::sub a;

        a.x();
	
        a.sub::x();
        a.base::x();

        a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}

        a.A::sub::x();
        a.A::B::base::x();

        a.bad::x(); // expected-error{{type 'bad' is not a direct or virtual base of ''A::sub''}}
    }

    void fun2()
    {
        A::sub *a;

        a->x();
	
        a->sub::x();
        a->base::x();

        a->B::base::x(); // expected-error{{use of undeclared identifier 'B'}}

        a->A::sub::x();
        a->A::B::base::x();

        a->bad::x(); // expected-error{{type 'bad' is not a direct or virtual base of ''A::sub''}}
    }

    void fun3()
    {
        int i;
        i.foo(); // expected-error{{member reference base type 'int' is not a structure or union}}
    }
}
