Clang Project

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