xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/warn-main.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
3*f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc // expected-note@+1 2{{previous definition is here}}
main()6*f4a2713aSLionel Sambuc int main() {
7*f4a2713aSLionel Sambuc   return 0;
8*f4a2713aSLionel Sambuc }
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc // expected-error@+2 {{static declaration of 'main' follows non-static declaration}}
11*f4a2713aSLionel Sambuc // expected-warning@+1 {{'main' should not be declared static}}
main()12*f4a2713aSLionel Sambuc static int main() {
13*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
14*f4a2713aSLionel Sambuc   return 0;
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc // expected-error@+2 {{redefinition of 'main'}}
18*f4a2713aSLionel Sambuc // expected-error@+1 {{'main' is not allowed to be declared inline}}
main()19*f4a2713aSLionel Sambuc inline int main() {
20*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
21*f4a2713aSLionel Sambuc   return 0;
22*f4a2713aSLionel Sambuc }
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // expected-warning@+5 {{function 'main' declared 'noreturn' should not return}}
25*f4a2713aSLionel Sambuc // expected-warning@+2 {{'main' is not allowed to be declared _Noreturn}}
26*f4a2713aSLionel Sambuc // expected-note@+1 {{remove '_Noreturn'}}
main()27*f4a2713aSLionel Sambuc _Noreturn int main() {
28*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:11}:""
29*f4a2713aSLionel Sambuc   return 0;
30*f4a2713aSLionel Sambuc }
31*f4a2713aSLionel Sambuc 
32