xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/macro-undef.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-pch -o %t %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -verify
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
4*0a6a1f1dSLionel Sambuc 
5*0a6a1f1dSLionel Sambuc #ifndef HEADER
6*0a6a1f1dSLionel Sambuc #define HEADER
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc #define NULL 0
9*0a6a1f1dSLionel Sambuc template<typename T>
f()10*0a6a1f1dSLionel Sambuc void *f() {
11*0a6a1f1dSLionel Sambuc   void *p;  // @11
12*0a6a1f1dSLionel Sambuc   return p; // @12
13*0a6a1f1dSLionel Sambuc }
14*0a6a1f1dSLionel Sambuc #undef NULL
15*0a6a1f1dSLionel Sambuc template<typename T>
g()16*0a6a1f1dSLionel Sambuc void *g() {
17*0a6a1f1dSLionel Sambuc   void *p;  // @17
18*0a6a1f1dSLionel Sambuc   return p; // @18
19*0a6a1f1dSLionel Sambuc }
20*0a6a1f1dSLionel Sambuc 
21*0a6a1f1dSLionel Sambuc #else
22*0a6a1f1dSLionel Sambuc 
23*0a6a1f1dSLionel Sambuc // expected-warning@12 {{uninitialized}}
24*0a6a1f1dSLionel Sambuc // expected-note@11 {{initialize}}
25*0a6a1f1dSLionel Sambuc // CHECK: fix-it:"{{.*}}":{11:10-11:10}:" = NULL"
26*0a6a1f1dSLionel Sambuc 
27*0a6a1f1dSLionel Sambuc // expected-warning@18 {{uninitialized}}
28*0a6a1f1dSLionel Sambuc // expected-note@17 {{initialize}}
29*0a6a1f1dSLionel Sambuc // CHECK: fix-it:"{{.*}}":{17:10-17:10}:" = 0"
30*0a6a1f1dSLionel Sambuc 
main()31*0a6a1f1dSLionel Sambuc int main() {
32*0a6a1f1dSLionel Sambuc   f<int>(); // expected-note {{instantiation}}
33*0a6a1f1dSLionel Sambuc   g<int>(); // expected-note {{instantiation}}
34*0a6a1f1dSLionel Sambuc }
35*0a6a1f1dSLionel Sambuc 
36*0a6a1f1dSLionel Sambuc #endif
37