[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 13 15:13:56 PDT 2022


rsmith added a comment.

It seems surprising to me for the diagnostic to change from warn-by-default to error-by-default when changing from C99 to C11, given that the language rule did not change between C99 and C11 (as a Clang user, when changing my `-std=` flag, I don't want other changes to come in that are unrelated to the language mode change I requested). I think we should just make this an error by default in C99 onwards; if we're happy promoting this from warning-by-default to error-by-default for the folks using `-std=c11` and later (and I think we are), then we should be happy doing the same for the `-std=c99` folks too -- especially given that C17 is the default everywhere other than on PS4.



================
Comment at: clang/lib/Sema/SemaDecl.cpp:15269
   if (II.getName().startswith("__builtin_"))
     diag_id = diag::warn_builtin_unknown;
   // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.
----------------
For consistency, this case should be an `ExtWarn`, not just a `Warning`, in C99 onwards (and an `Error` in C2x, which it will be because we don't get here in that case). But given that this is within the implementation namespace and it's currently a `DefaultError`, perhaps we should instead fully replace this `Warning` with an `Error` in all language modes?


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

https://reviews.llvm.org/D122983



More information about the cfe-commits mailing list