p2.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST1
  2. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST2
  3. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST3
  4. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST4
  5. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST5
  6. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST6
  7. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST7
  8. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST8
  9. // RUN: cp %s %t
  10. // RUN: %clang_cc1 -x c++ %s -std=c++11 -fsyntax-only -verify -DTEST9
  11. // RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit -DTEST9
  12. // RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only -DTEST9
  13. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10
  14. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST11
  15. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12
  16. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST13
  17. // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST14
  18. #if TEST1
  19. // expected-no-diagnostics
  20. typedef int Int;
  21. typedef char Char;
  22. typedef Char* Carp;
  23. Int main(Int argc, Carp argv[]) {
  24. }
  25. #elif TEST2
  26. // expected-no-diagnostics
  27. typedef int Int;
  28. typedef char Char;
  29. typedef Char* Carp;
  30. Int main(Int argc, Carp argv[], Char *env[]) {
  31. }
  32. #elif TEST3
  33. // expected-no-diagnostics
  34. int main() {
  35. }
  36. #elif TEST4
  37. static int main() { // expected-error {{'main' is not allowed to be declared static}}
  38. }
  39. #elif TEST5
  40. inline int main() { // expected-error {{'main' is not allowed to be declared inline}}
  41. }
  42. #elif TEST6
  43. void // expected-error {{'main' must return 'int'}}
  44. main( // expected-error {{first parameter of 'main' (argument count) must be of type 'int'}}
  45. float a
  46. ) {
  47. }
  48. const int main(); // expected-error {{'main' must return 'int'}}
  49. #elif TEST7
  50. // expected-no-diagnostics
  51. int main(int argc, const char* const* argv) {
  52. }
  53. #elif TEST8
  54. template<typename T>
  55. int main() { } // expected-error{{'main' cannot be a template}}
  56. #elif TEST9
  57. constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}}
  58. #elif TEST10
  59. // PR15100
  60. // expected-no-diagnostics
  61. typedef char charT;
  62. int main(int, const charT**) {}
  63. #elif TEST11
  64. // expected-no-diagnostics
  65. typedef char charT;
  66. int main(int, charT* const *) {}
  67. #elif TEST12
  68. // expected-no-diagnostics
  69. typedef char charT;
  70. int main(int, const charT* const *) {}
  71. #elif TEST13
  72. int main(void) {}
  73. template <typename T>
  74. int main(void); // expected-error{{'main' cannot be a template}}
  75. #elif TEST14
  76. template <typename T>
  77. int main(void); // expected-error{{'main' cannot be a template}}
  78. int main(void) {}
  79. #else
  80. #error Unknown test mode
  81. #endif