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