p3.cpp 902 B

123456789101112131415161718192021222324
  1. // RUN: %clang_cc1 -verify %s -pedantic-errors
  2. // RUN: %clang_cc1 -verify %s -pedantic-errors -DINLINE
  3. // RUN: %clang_cc1 -verify %s -pedantic-errors -DSTATIC
  4. // RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 -DCONSTEXPR
  5. // RUN: %clang_cc1 -verify %s -std=c++11 -DDELETED
  6. #if INLINE
  7. inline // expected-error {{'main' is not allowed to be declared inline}}
  8. #elif STATIC
  9. static // expected-error {{'main' is not allowed to be declared static}}
  10. #elif CONSTEXPR
  11. constexpr // expected-error {{'main' is not allowed to be declared constexpr}}
  12. #endif
  13. int main(int argc, char **argv)
  14. #if DELETED
  15. = delete; // expected-error {{'main' is not allowed to be deleted}}
  16. #else
  17. {
  18. int (*pmain)(int, char**) = &main; // expected-error {{ISO C++ does not allow 'main' to be used by a program}}
  19. if (argc)
  20. main(0, 0); // expected-error {{ISO C++ does not allow 'main' to be used by a program}}
  21. }
  22. #endif