verify3.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // This test-case runs several sub-tests on -verify to ensure that correct
  2. // diagnostics are generated in relation to the mis-use and non-use of the
  3. // 'expected-no-diagnostics' directive.
  4. // RUN: not %clang_cc1 -DTEST1 -verify %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
  5. #ifdef TEST1
  6. // expected-no-diagnostics
  7. // expected-note {{}}
  8. // CHECK1: error: 'error' diagnostics seen but not expected:
  9. // CHECK1-NEXT: Line 8: expected directive cannot follow 'expected-no-diagnostics' directive
  10. // CHECK1-NEXT: 1 error generated.
  11. #endif
  12. // RUN: not %clang_cc1 -DTEST2 -verify %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
  13. #ifdef TEST2
  14. #warning X
  15. // expected-warning@-1 {{X}}
  16. // expected-no-diagnostics
  17. // CHECK2: error: 'error' diagnostics seen but not expected:
  18. // CHECK2-NEXT: Line 19: 'expected-no-diagnostics' directive cannot follow other expected directives
  19. // CHECK2-NEXT: 1 error generated.
  20. #endif
  21. // RUN: not %clang_cc1 -DTEST3 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
  22. // RUN: not %clang_cc1 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
  23. #ifdef TEST3
  24. // no directives
  25. // CHECK3: error: no expected directives found: consider use of 'expected-no-diagnostics'
  26. // CHECK3-NEXT: 1 error generated.
  27. #endif
  28. // RUN: %clang_cc1 -E -DTEST4 -verify %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
  29. #ifdef TEST4
  30. #warning X
  31. // expected-warning@-1 {{X}}
  32. // CHECK4-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics'
  33. #endif