[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / pragma-diag-section.cpp
blob7f72f3ce679a6ffffd4efaa83bea4d777b0414e9
1 // Test this without pch.
2 // RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -Wuninitialized
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
8 // RUN: %clang_cc1 %s -emit-pch -fpch-instantiate-templates -o %t
9 // RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
11 #ifndef HEADER
12 #define HEADER
14 #pragma clang diagnostic push
15 #pragma clang diagnostic ignored "-Wuninitialized"
16 template <typename T>
17 struct TS1 {
18 void m() {
19 T a;
20 T b = a;
23 #pragma clang diagnostic pop
25 #else
28 template <typename T>
29 struct TS2 {
30 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}}
38 void f() {
39 TS1<int> ts1;
40 ts1.m();
43 TS2<int> ts2;
44 ts2.m();
47 #endif