warn-main.c 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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
  4. // expected-note@+1 2{{previous definition is here}}
  5. int main() {
  6. return 0;
  7. }
  8. // expected-error@+2 {{static declaration of 'main' follows non-static declaration}}
  9. // expected-warning@+1 {{'main' should not be declared static}}
  10. static int main() {
  11. // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
  12. return 0;
  13. }
  14. // expected-error@+2 {{redefinition of 'main'}}
  15. // expected-error@+1 {{'main' is not allowed to be declared inline}}
  16. inline int main() {
  17. // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:8}:""
  18. return 0;
  19. }
  20. // expected-warning@+5 {{function 'main' declared 'noreturn' should not return}}
  21. // expected-warning@+2 {{'main' is not allowed to be declared _Noreturn}}
  22. // expected-note@+1 {{remove '_Noreturn'}}
  23. _Noreturn int main() {
  24. // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:1-[[@LINE-1]]:11}:""
  25. return 0;
  26. }
  27. // expected-warning@+1 {{'main' is not allowed to be declared variadic}}
  28. int main(int argc, char**argv, ...) { return 0; }