[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / warn-main.c
blob8625fdd09ee929348bf4a596bb8297cfc41b1dde
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
3 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
5 // expected-note@+1 2{{previous definition is here}}
6 int main(void) {
7 return 0;
10 // expected-error@+2 {{static declaration of 'main' follows non-static declaration}}
11 // expected-warning@+1 {{'main' should not be declared static}}
12 static int main(void) {
13 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
14 return 0;
17 // expected-error@+2 {{redefinition of 'main'}}
18 // expected-error@+1 {{'main' is not allowed to be declared inline}}
19 inline int main(void) {
20 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
21 return 0;
24 // expected-warning@+5 {{function 'main' declared 'noreturn' should not return}}
25 // expected-warning@+2 {{'main' is not allowed to be declared _Noreturn}}
26 // expected-note@+1 {{remove '_Noreturn'}}
27 _Noreturn int main(void) {
28 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:11}:""
29 return 0;
32 // expected-warning@+1 {{'main' is not allowed to be declared variadic}}
33 int main(int argc, char**argv, ...) { return 0; }