templates.cpp revision 45246a7fc00f07bba9a34a3f13c0af72a05f95be
1// RUN: %clang_cc1 -analyze -analyzer-checker=core -fblocks -verify %s
2
3// Do not crash on this templated code which uses a block.
4typedef void (^my_block)(void);
5static void useBlock(my_block block){}
6template<class T> class MyClass;
7typedef MyClass<float> Mf;
8
9template<class T>
10class MyClass
11{
12public:
13  MyClass() {}
14  MyClass(T a);
15  void I();
16private:
17 static const T one;
18};
19
20template<class T> const T MyClass<T>::one = static_cast<T>(1);
21template<class T> inline MyClass<T>::MyClass(T a){}
22template<class T> void MyClass<T>::I() {
23  static MyClass<T>* mPtr = 0;
24  useBlock(^{ mPtr = new MyClass<T> (MyClass<T>::one); });
25};
26int main(){
27  Mf m;
28  m.I();
29}
30