summaryrefslogtreecommitdiff
path: root/test/Parser/DelayedTemplateParsing.cpp
blob: bcd286ae044921ed083eb0a22002825986800158 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify -std=c++11 %s

template <class T>
class A {
   void foo() {
       undeclared();
   }
   void foo2();
};

template <class T>
class B {
   void foo4() { } // expected-note {{previous definition is here}}
   void foo4() { } // expected-error {{class member cannot be redeclared}}
   void foo5() { } // expected-note {{previous definition is here}}

   friend void foo3() {
       undeclared();
   }
};


template <class T>
void B<T>::foo5() { // expected-error {{redefinition of 'foo5'}}
}

template <class T>
void A<T>::foo2() {
    undeclared();
}


template <class T>
void foo3() {
   undeclared();
}

template void A<int>::foo2();


void undeclared()
{

}

template <class T> void foo5() {} //expected-note {{previous definition is here}} 
template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}}

              


namespace PR11931 {

template <typename RunType>
struct BindState;

  template<>
struct BindState<void(void*)> {
  static void Run() { }
};

class Callback {
public:
  typedef void RunType();

  template <typename RunType>
  Callback(BindState<RunType> bind_state) {
    BindState<RunType>::Run();
  }
};


Callback Bind() {
  return Callback(BindState<void(void*)>());
}

}

namespace rdar11700604 {
  template<typename T> void foo() = delete;

  struct X {
    X() = default;

    template<typename T> void foo() = delete;
  };
}

namespace PR17334 {

template <typename = void> struct ArrayRef {
  constexpr ArrayRef() {}
};
template <typename = void> void CreateConstInBoundsGEP2_32() {
  ArrayRef<> IdxList;
}
void LLVMBuildStructGEP() { CreateConstInBoundsGEP2_32(); }

}

namespace PR17661 {
template <typename T>
constexpr T Fun(T A) { return T(0); }

constexpr int Var = Fun(20);
}

template <typename T>
auto invalidTrailingRetType() -> Bogus {} // expected-error {{unknown type name 'Bogus'}}

namespace PR19613 {

struct HeapTypeConfig {
  static void from_bitset();
};

template <class Config>
struct TypeImpl  {
  struct BitsetType;

  static void Any() {
    BitsetType::New();
  }
};

template<class Config>
struct TypeImpl<Config>::BitsetType {
  static void New() {
    Config::from_bitset();
  }
};

static void f() {
  TypeImpl<HeapTypeConfig>::Any();
}

template<typename A> struct S {
  template<typename B> struct T;
};
template<typename A> template<typename B> struct S<A>::T {
  template<typename C, typename D> struct U;
  template<typename C> struct U<C, C> {
    template<typename E> static int f() {
      return sizeof(A) + sizeof(B) + sizeof(C) + sizeof(E);
    }
  };
};

static void g() {
  S<int>::T<int>::U<int,int>::f<int>();
}

template<typename T> struct SS {
  template<typename U> struct X;
  template<typename U> struct X<U*>;
};
template<typename T> template<typename U> struct SS<T>::X<U*> {
  static int f() {
    return sizeof(T) + sizeof(U);
  }
};

static void h() {
  SS<int>::X<int*>::f();
}

}

struct PR38460 {
  template <typename>
  struct T {
    static void foo() {
      struct U {
        void dummy() {
          use_delayed_identifier();
        }
      };
    }
  };
};
void use_delayed_identifier();
void trigger_PR38460() {
  PR38460::T<int>::foo();
}

template <typename> struct PR38460_2 {
  struct p {
    struct G {
      bool operator()(int) {}
    };
  };
  static void as() {
    typename p::G g;
    g(0);
  }
};
template struct PR38460_2<int>;