[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 30 10:38:57 PDT 2022

aaron.ballman added a comment.

In D122895#3484097 <https://reviews.llvm.org/D122895#3484097>, @aaron.ballman wrote:

> In D122895#3484076 <https://reviews.llvm.org/D122895#3484076>, @manojgupta wrote:
>> Tried locally but I still see the warning with -fno-knr-functions. It also says that the argument is unused.
>> bin/clang --version
>> clang version 15.0.0 (https://github.com/llvm/llvm-project.git a9d68a5524dea113cace5983697786599cbdce9a <https://reviews.llvm.org/rGa9d68a5524dea113cace5983697786599cbdce9a>)
>> Target: x86_64-unknown-linux-gnu
>> $ cat pr.c
>> void foo(void);
>> void foo() 
>> {
>> }
>> $ bin/clang -c pr.c -Wstrict-prototypes -fno-knr-functions
>> clang-14: warning: argument unused during compilation: '-fno-knr-functions' [-Wunused-command-line-argument]
>> pr.c:3:9: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
>> void foo()
>>   ^
>>    void
>> 1 warning generated.
>> It works if -fno-knr-functions is passed with Xclang .  Is it intentional that -fno-knr-functions is only a cc1 option? That makes it very hard for us to enable it.
>> $ bin/clang -c pr.c -Wstrict-prototypes -Xclang -fno-knr-functions (no warnings)
> No, that's not at all intentional -- it should be exposed as a driver flag. I can reproduce the issue locally and will fix this today (it's very strange because the option is listed as a CoreOption should it should be exposed through the driver). I'm very sorry for the trouble, but thank you for catching this!

Sheesh, I added the driver tests to make sure we don't accept a negated version of the flag, but I didn't add the test to validate that the driver accepted the flag, which is why I didn't catch this before. I've corrected the problem and added test coverage in 786954db06ab253dbd62d059036e06f6bbd9223c <https://reviews.llvm.org/rG786954db06ab253dbd62d059036e06f6bbd9223c>. Thanks for letting me know about the issue!

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list