[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 5 07:24:03 PDT 2019


aaron.ballman added a comment.

In D66919#1658483 <https://reviews.llvm.org/D66919#1658483>, @aaronpuchert wrote:

> In D66919#1658355 <https://reviews.llvm.org/D66919#1658355>, @aaron.ballman wrote:
>
> > We do have numerous warnings that are default errors, you can look for `DefaultError` in the diagnostic .td files to see the uses.
>
>
> Thanks, I hadn't seen that before. It seems that most of these warnings are for extensions, but one comes pretty close to what @dexonsmith has suggested:
>
>   def warn_cannot_pass_non_pod_arg_to_vararg : Warning<
>     "cannot pass object of %select{non-POD|non-trivial}0 type %1 through variadic"
>     " %select{function|block|method|constructor}2; call will abort at runtime">,
>     InGroup<NonPODVarargs>, DefaultError;
>
>
> The standard explicitly says in C11 6.5.2.2p8: “the number and types of arguments are not compared with those of the parameters in a function definition that does not include a function prototype declarator”, but perhaps this just means a programmer can't rely on such a check?


I read that as stating that such a check does not happen. However, the standard places very little requirements on diagnostics; it's always permissible to take undefined behavior and define it to do something, such as diagnosing as a warning or an error, as a matter of QoI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66919





More information about the cfe-commits mailing list