1bd0dfa5c37d422427080a0ae3af9b63e70e6e854John McCall// RUN: %clang_cc1 -fsyntax-only -verify %s
2bd0dfa5c37d422427080a0ae3af9b63e70e6e854John McCall
3bd0dfa5c37d422427080a0ae3af9b63e70e6e854John McCall// PR5741
484d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCallnamespace test0 {
584d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  struct A {
684d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall    struct B { };
784d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall    struct C;
884d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  };
9bd0dfa5c37d422427080a0ae3af9b63e70e6e854John McCall
1084d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  struct A::C : B { };
1184d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall}
1284d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall
13f9368159334ff86ea5fa367225c1a580977f3b03John McCall// Test that successive base specifiers don't screw with each other.
1484d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCallnamespace test1 {
1584d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  struct Opaque1 {};
1684d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  struct Opaque2 {};
1784d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall
1884d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  struct A {
1984d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall    struct B { B(Opaque1); };
2084d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  };
2184d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  struct B {
2284d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall    B(Opaque2);
2384d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  };
2484d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall
2584d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  struct C : A, B {
2684d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall    // Apparently the base-or-member lookup is actually ambiguous
2784d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall    // without this qualification.
2884d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall    C() : A(), test1::B(Opaque2()) {}
2984d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall  };
3084d11c7ba48023b2bd3375ef002e08fecdb186ceJohn McCall}
31f9368159334ff86ea5fa367225c1a580977f3b03John McCall
32f9368159334ff86ea5fa367225c1a580977f3b03John McCall// Test that we don't find the injected class name when parsing base
33f9368159334ff86ea5fa367225c1a580977f3b03John McCall// specifiers.
34f9368159334ff86ea5fa367225c1a580977f3b03John McCallnamespace test2 {
35db88d8ad74097e2601d81ee863ce46a8a48a7034Jeffrey Yasskin  template <class T> struct bar {};
364b02dff7aebb98d2d60b2ff4d3fc86109213128cDavid Blaikie  template <class T> struct foo : bar<foo> {}; // expected-error {{use of class template 'foo' requires template arguments}} expected-note {{template is declared here}}
37f9368159334ff86ea5fa367225c1a580977f3b03John McCall}
38