empty-with-headers.c 763 B

123456789101112131415161718192021222324252627
  1. // RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic-errors %s
  2. // RUN: %clang_cc1 -fsyntax-only -std=c99 -emit-pch -o %t %s
  3. // RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic-errors -include-pch %t %s
  4. // RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic-errors -DINCLUDED %s -verify
  5. // This last one should warn for -Wempty-translation-unit (C99 6.9p1).
  6. #if defined(INCLUDED)
  7. // empty except for the prefix header
  8. #elif defined(HEADER)
  9. typedef int my_int;
  10. #define INCLUDED
  11. #else
  12. #define HEADER
  13. #include "empty-with-headers.c"
  14. // empty except for the header
  15. #endif
  16. // This should only fire if the header is not included,
  17. // either explicitly or as a prefix header.
  18. // expected-error{{ISO C requires a translation unit to contain at least one declaration}}