summaryrefslogtreecommitdiffstats
path: root/test/SemaTemplate/local-member-templates.cpp
blob: 3cdf5df8d143c63ef54fcde55a0fd4954285309d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// RUN: %clang_cc1 -std=c++1y -verify %s
// RUN: %clang_cc1 -std=c++1y -verify %s -fdelayed-template-parsing

namespace nested_local_templates_1 {

template <class T> struct Outer {
  template <class U> int outer_mem(T t, U u) {
    struct Inner {
      template <class V> int inner_mem(T t, U u, V v) {
        struct InnerInner {
          template <class W> int inner_inner_mem(W w, T t, U u, V v) {
            return 0;
          }
        };
        InnerInner().inner_inner_mem("abc", t, u, v);
        return 0;
      }
    };
    Inner i;
    i.inner_mem(t, u, 3.14);
    return 0;
  }

  template <class U> int outer_mem(T t, U *u);
};

template int Outer<int>::outer_mem(int, char);

template <class T> template <class U> int Outer<T>::outer_mem(T t, U *u) {
  struct Inner {
    template <class V>
    int inner_mem(T t, U u, V v) { //expected-note{{candidate function}}
      struct InnerInner {
        template <class W> int inner_inner_mem(W w, T t, U u, V v) { return 0; }
      };
      InnerInner().inner_inner_mem("abc", t, u, v);
      return 0;
    }
  };
  Inner i;
  i.inner_mem(t, U{}, i);
  i.inner_mem(t, u, 3.14); //expected-error{{no matching member function for call to 'inner}}
  return 0;
}

template int Outer<int>::outer_mem(int, char *); //expected-note{{in instantiation of function}}

} // end ns

namespace nested_local_templates_2 {

template <class T> struct Outer {
  template <class U> void outer_mem(T t, U u) {
    struct Inner {
      template <class V> struct InnerTemplateClass {
        template <class W>
        void itc_mem(T t, U u, V v, W w) { //expected-note{{candidate function}}
          struct InnerInnerInner {
            template <class X> void iii_mem(X x) {}
          };
          InnerInnerInner i;
          i.iii_mem("abc");
        }
      };
    };
    Inner i;
    typename Inner::template InnerTemplateClass<Inner> ii;
    ii.itc_mem(t, u, i, "jim");
    ii.itc_mem(t, u, 0, "abd"); //expected-error{{no matching member function}}
  }
};

template void
Outer<int>::outer_mem(int, char); //expected-note{{in instantiation of}}

}
OpenPOWER on IntegriCloud