Functions without prototypes in C (also known as K&R C functions) were introduced into C89 as a deprecated feature and C2x is now reclaiming that syntax space with different semantics. However, Clang's -Wstrict-prototypes diagnostic is off-by-default (even in pedantic mode) and does not suffice to warn users about issues in their code.
This patch changes the behavior of -Wstrict-prototypes to only diagnose declarations and definitions which are not going to change behavior in C2x mode, and enables the diagnostic in -pedantic mode. The diagnostic is now specifically about the fact that the feature is deprecated.
It also adds -Wdeprecated-non-prototype, which is grouped under -Wstrict-prototypes and diagnoses declarations or definitions which will change behavior in C2x mode. This diagnostic is enabled by default because the risk is higher for the user to continue to use the deprecated feature.
A few things to note:
- The RFC for this can be found at: https://discourse.llvm.org/t/rfc-enabling-wstrict-prototypes-by-default-in-c
- There is some awkward overlap between the diagnostics, but the best time to diagnose a function type without a prototype is when forming the function type, but we don't know whether the behavior will change in C2x at that point. So we alter the behavior sometimes depending on whether -Wstrict-prototypes is enabled in an effort to keep the diagnostics understandable and not too chatty.
- There will be another patch for handling call site behavior as a follow-up.
"declaration of a function without a prototype is deprecated", may be slightly better?