48 lines · cpp
1// Test this without pch.2// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -Wuninitialized3 4// Test with pch.5// RUN: %clang_cc1 %s -emit-pch -o %t6// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized7 8// RUN: %clang_cc1 %s -emit-pch -fpch-instantiate-templates -o %t9// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized10 11#ifndef HEADER12#define HEADER13 14#pragma clang diagnostic push15#pragma clang diagnostic ignored "-Wuninitialized"16template <typename T>17struct TS1 {18 void m() {19 T a;20 T b = a;21 }22};23#pragma clang diagnostic pop24 25#else26 27 28template <typename T>29struct 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}}35 }36};37 38void f() {39 TS1<int> ts1;40 ts1.m();41 42 43 TS2<int> ts2;44 ts2.m();45}46 47#endif48