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 
10 // RUN: cp %s %t
11 // RUN: %clang_cc1 -x c++ %s -std=c++11 -fsyntax-only -verify -DTEST9
12 // RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit -DTEST9
13 // REQUIRES: rewriter
14 // RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only -DTEST9
15 
16 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10
17 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST11
18 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12
19 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST13
20 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST14
21 
22 #if TEST1
23 
24 // expected-no-diagnostics
25 typedef int Int;
26 typedef char Char;
27 typedef Char* Carp;
28 
29 Int main(Int argc, Carp argv[]) {
30 }
31 
32 #elif TEST2
33 
34 // expected-no-diagnostics
35 typedef int Int;
36 typedef char Char;
37 typedef Char* Carp;
38 
39 Int main(Int argc, Carp argv[], Char *env[]) {
40 }
41 
42 #elif TEST3
43 
44 // expected-no-diagnostics
45 int main() {
46 }
47 
48 #elif TEST4
49 
50 static int main() { // expected-error {{'main' is not allowed to be declared static}}
51 }
52 
53 #elif TEST5
54 
55 inline int main() { // expected-error {{'main' is not allowed to be declared inline}}
56 }
57 
58 #elif TEST6
59 
60 void  // expected-error {{'main' must return 'int'}}
61 main( // expected-error {{first parameter of 'main' (argument count) must be of type 'int'}}
62      float a
63 ) {
64 }
65 
66 const int main(); // expected-error {{'main' must return 'int'}}
67 
68 #elif TEST7
69 
70 // expected-no-diagnostics
71 int main(int argc, const char* const* argv) {
72 }
73 
74 #elif TEST8
75 
76 template<typename T>
77 int main() { } // expected-error{{'main' cannot be a template}}
78 
79 #elif TEST9
80 
81 constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}}
82 
83 #elif TEST10
84 
85 // PR15100
86 // expected-no-diagnostics
87 typedef char charT;
88 int main(int, const charT**) {}
89 
90 #elif TEST11
91 
92 // expected-no-diagnostics
93 typedef char charT;
94 int main(int, charT* const *) {}
95 
96 #elif TEST12
97 
98 // expected-no-diagnostics
99 typedef char charT;
100 int main(int, const charT* const *) {}
101 
102 #elif TEST13
103 
104 int main(void) {}
105 
106 template <typename T>
107 int main(void); // expected-error{{'main' cannot be a template}}
108 
109 #elif TEST14
110 
111 template <typename T>
112 int main(void); // expected-error{{'main' cannot be a template}}
113 
114 int main(void) {}
115 
116 #else
117 
118 #error Unknown test mode
119 
120 #endif
121