macro-undef.cpp 814 B

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