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

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 13 07:44:32 PDT 2022


dexonsmith added a comment.

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

> In D122895#3511611 <https://reviews.llvm.org/D122895#3511611>, @dexonsmith wrote:
>
>> Sure, I'm all for adding a new warning for users that want a pedantic warning. Can it be put behind a separate flag, such as `-Wstrict-prototypes-pedantic`, which isn't triggered by `-Wstrict-prototypes`?
>>
>> Previously, `-Wstrict-prototypes` was useful for preventing actual bugs in code.
>
> Doing that would then make `-Wstrict-prototypes` effectively a no-op (it would still control `-Wdeprecated-non-prototype` I suppose?),

Is it necessary to make `-Wstrict-prototypes` weaker in order to move the newer more pedantic cases to a different name?

> but there were also people who enabled `-Wstrict-prototypes` because they wanted the pedantic aspects of the warning in cases where it was firing, and those folks would then be losing warning coverage without knowing it. For example:
>
>   void f(){}
>
> In prior versions of Clang with `-Wstrict-prototypes` this would issue a `this old-style function definition is not preceded by a prototype` diagnostic, but would now be silenced entirely unless the user knew to turn on a different flag.

Oh, I thought that would catch bugs like this:

  void longfunctionname(){}
  void longfunctionnames(int x){ /* do something with x */ }
  
  void g(void) {
    longfunctionname(7); // oops, meant to call longfunctionnames().
  }

but if it's entirely pedantic (if the call to `longfunctionname(7)` would fail to compile) then I agree it'd be better to silence it unless someone asks for `-pedantic`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122895/new/

https://reviews.llvm.org/D122895



More information about the cfe-commits mailing list