1 // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fblocks -verify %s
2 
3 void clang_analyzer_eval(bool);
4 
5 // Do not crash on this templated code which uses a block.
6 typedef void (^my_block)(void);
7 static void useBlock(my_block block){}
8 template<class T> class MyClass;
9 typedef MyClass<float> Mf;
10 
11 template<class T>
12 class MyClass
13 {
14 public:
15   MyClass() {}
16   MyClass(T a);
17   void I();
18 private:
19  static const T one;
20 };
21 
22 template<class T> const T MyClass<T>::one = static_cast<T>(1);
23 template<class T> inline MyClass<T>::MyClass(T a){}
24 template<class T> void MyClass<T>::I() {
25   static MyClass<T>* mPtr = 0;
26   useBlock(^{ mPtr = new MyClass<T> (MyClass<T>::one); });
27 };
28 int main(){
29   Mf m;
30   m.I();
31 }
32 
33 
34 // <rdar://problem/11949235>
35 template<class T, unsigned N>
36 inline unsigned array_lengthof(T (&)[N]) {
37   return N;
38 }
39 
40 void testNonTypeTemplateInstantiation() {
41   const char *S[] = { "a", "b" };
42   clang_analyzer_eval(array_lengthof(S) == 2); // expected-warning{{TRUE}}
43 }
44 
45