Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / basic / basic.start / basic.start.main / p2.cpp
blob42e87e5431f2a5ba056416ca994d510f4224dc86
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
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
15 // 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
18 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST13
19 // RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST14
21 #if TEST1
23 // expected-no-diagnostics
24 typedef int Int;
25 typedef char Char;
26 typedef Char* Carp;
28 Int main(Int argc, Carp argv[]) {
31 #elif TEST2
33 // expected-no-diagnostics
34 typedef int Int;
35 typedef char Char;
36 typedef Char* Carp;
38 Int main(Int argc, Carp argv[], Char *env[]) {
41 #elif TEST3
43 // expected-no-diagnostics
44 int main() {
47 #elif TEST4
49 static int main() { // expected-error {{'main' is not allowed to be declared static}}
52 #elif TEST5
54 inline int main() { // expected-error {{'main' is not allowed to be declared inline}}
57 #elif TEST6
59 void // expected-error {{'main' must return 'int'}}
60 main( // expected-error {{first parameter of 'main' (argument count) must be of type 'int'}}
61 float a
62 ) {
65 const int main(); // expected-error {{'main' must return 'int'}}
67 #elif TEST7
69 // expected-no-diagnostics
70 int main(int argc, const char* const* argv) {
73 #elif TEST8
75 template<typename T>
76 int main() { } // expected-error{{'main' cannot be a template}}
78 #elif TEST9
80 constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}}
82 #elif TEST10
84 // PR15100
85 // expected-no-diagnostics
86 typedef char charT;
87 int main(int, const charT**) {}
89 #elif TEST11
91 // expected-no-diagnostics
92 typedef char charT;
93 int main(int, charT* const *) {}
95 #elif TEST12
97 // expected-no-diagnostics
98 typedef char charT;
99 int main(int, const charT* const *) {}
101 #elif TEST13
103 int main(void) {}
105 template <typename T>
106 int main(void); // expected-error{{'main' cannot be a template}}
108 #elif TEST14
110 template <typename T>
111 int main(void); // expected-error{{'main' cannot be a template}}
113 int main(void) {}
115 #else
117 #error Unknown test mode
119 #endif