Can't get -Wstrict-prototypes to work

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't get -Wstrict-prototypes to work

Fangrui Song via cfe-dev
Can't get -Wstrict-prototypes to work 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!
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can't get -Wstrict-prototypes to work

Fangrui Song via cfe-dev
On Thu, Apr 2, 2020 at 7:20 AM Ray Mitchell via cfe-dev
<[hidden email]> 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).

~Aaron


> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev