pragma-diag-section.cpp 849 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Test this without pch.
  2. // RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -Wuninitialized
  3. // Test with pch.
  4. // RUN: %clang_cc1 %s -emit-pch -o %t
  5. // RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
  6. #ifndef HEADER
  7. #define HEADER
  8. #pragma clang diagnostic push
  9. #pragma clang diagnostic ignored "-Wuninitialized"
  10. template <typename T>
  11. struct TS1 {
  12. void m() {
  13. T a;
  14. T b = a;
  15. }
  16. };
  17. #pragma clang diagnostic pop
  18. #else
  19. template <typename T>
  20. struct TS2 {
  21. void m() {
  22. T a;
  23. T b = a; // expected-warning {{variable 'a' is uninitialized}} \
  24. expected-note@41 {{in instantiation of member function}} \
  25. expected-note@28 {{initialize the variable 'a' to silence}}
  26. }
  27. };
  28. void f() {
  29. TS1<int> ts1;
  30. ts1.m();
  31. TS2<int> ts2;
  32. ts2.m();
  33. }
  34. #endif