1 // RUN: %clang_cc1 -std=c++11 -verify %s
2 
3 namespace PR40329 {
4   struct A {
5     A(int);
6     friend int operator->*(A, A);
7   };
8   struct B : A {
9     B();
10     enum E { e };
11   };
12   // Associated classes for B are {B, A}
13   // Associated classes for B::E are {B} (non-transitive in this case)
14   //
15   // If we search B::E first, we must not mark B "visited" and shortcircuit
16   // visiting it later, or we won't find the associated class A.
17   int k0 = B::e ->* B::e; // expected-error {{non-pointer-to-member type}}
18   int k1 = B::e ->* B();
19   int k2 = B() ->* B::e;
20 }
21