[cfe-dev] Can't get -Wstrict-prototypes to work

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Thu Apr 2 05:11:25 PDT 2020

On Thu, Apr 2, 2020 at 7:20 AM Ray Mitchell via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> I am using:  clang version 9.0.0 based upon LLVM 9.0.0-r351376 default target i686-pc-windows-msvc
> and my command line is:  clang -Wstrict-prototypes Test.c
> The contents of the file is:  int main() { return 0; }
> I was expecting to get a warning about not having the keyword void in the parameter list, but I don't get one.  I do get this warning with minGW when this option is specified.  Is this a bug or am I missing something?  Thanks!

Looking at the code, it appears to be an explicit decision
(ShouldWarnAboutMissingPrototype() in SemaDecl.cpp explicitly does not
warn about main()). I have not looked back through history of the
feature, but I would guess that this was done because the reason why
you want strict prototypes in C is because you don't want to
accidentally call the function with the wrong arguments, and you don't
typically call main() directly (even though it's allowed by C).


> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list