1 // Test this without pch.
2 // RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -Wuninitialized
3 
4 // Test with pch.
5 // RUN: %clang_cc1 %s -emit-pch -o %t
6 // RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
7 
8 // RUN: %clang_cc1 %s -emit-pch -fpch-instantiate-templates -o %t
9 // RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
10 
11 #ifndef HEADER
12 #define HEADER
13 
14 #pragma clang diagnostic push
15 #pragma clang diagnostic ignored "-Wuninitialized"
16 template <typename T>
17 struct TS1 {
mTS118     void m() {
19       T a;
20       T b = a;
21     }
22 };
23 #pragma clang diagnostic pop
24 
25 #else
26 
27 
28 template <typename T>
29 struct TS2 {
mTS230     void m() {
31       T a;
32       T b = a; // expected-warning {{variable 'a' is uninitialized}} \
33                   expected-note@44 {{in instantiation of member function}} \
34                   expected-note@31 {{initialize the variable 'a' to silence}}
35     }
36 };
37 
f()38 void f() {
39     TS1<int> ts1;
40     ts1.m();
41 
42 
43     TS2<int> ts2;
44     ts2.m();
45 }
46 
47 #endif
48