12d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor// RUN: %clang_cc1 -fsyntax-only -verify %s
28e8fb3be5bd78f0564444eca02b404566a5f3b5dAndy Gibbs// expected-no-diagnostics
32d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor
42d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor// PR5787
52d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregorclass C {
62d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor public:
72d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor  ~C() {}
82d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor};
92d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor
102d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregortemplate <typename T>
112d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregorclass E {
122d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor public:
132d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor  E& Foo(const C&);
142d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor  E& Bar() { return Foo(C()); }
152d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor};
162d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor
172d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregorvoid Test() {
182d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor  E<int> e;
192d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor  e.Bar();
202d48e7811216b2a2d15dcf7e4be8f73ad48cc60aDouglas Gregor}
21