1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s
28e8fb3be5bd78f0564444eca02b404566a5f3b5dAndy Gibbs// expected-no-diagnostics
3e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall
4e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCalltemplate <class T> struct A {
5e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall  static T cond;
6e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall
7e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall  template <class U> struct B {
8e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall    static T twice(U value) {
9e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall      return (cond ? value + value : value);
10e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall    }
11e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall  };
12e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall};
13e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall
14e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCallint foo() {
15e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall  A<bool>::cond = true;
16e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall  return A<bool>::B<int>::twice(4);
17e29ba20148e9b7835ad463b39cd4ee9223eafbbfJohn McCall}
1821d53e179651657e243587b79234fe6fedfae71cDouglas Gregor
1921d53e179651657e243587b79234fe6fedfae71cDouglas Gregornamespace PR6376 {
2021d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  template<typename T>
2121d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  struct X {
2221d53e179651657e243587b79234fe6fedfae71cDouglas Gregor    template<typename Y>
2357265e35292897e383d70bbd1d552209fac37b39Douglas Gregor    struct Y1 { }; //
2421d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  };
2521d53e179651657e243587b79234fe6fedfae71cDouglas Gregor
2621d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  template<>
2721d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  struct X<float> {
2821d53e179651657e243587b79234fe6fedfae71cDouglas Gregor    template<typename Y>
2957265e35292897e383d70bbd1d552209fac37b39Douglas Gregor    struct Y1 { };
3021d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  };
3121d53e179651657e243587b79234fe6fedfae71cDouglas Gregor
3221d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  template<typename T, typename U>
3357265e35292897e383d70bbd1d552209fac37b39Douglas Gregor  struct Z : public X<T>::template Y1<U> { };
3421d53e179651657e243587b79234fe6fedfae71cDouglas Gregor
3521d53e179651657e243587b79234fe6fedfae71cDouglas Gregor  Z<float, int> z0;
3621d53e179651657e243587b79234fe6fedfae71cDouglas Gregor}
37