[clang] [Sema] Suggest missing format attributes (PR #166738)

Vladimir Vuksanovic via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 7 03:17:15 PST 2025


vvuksanovic wrote:

> > We probably want to only emit this diagnostic (or perform the check at all really) if we’re in `-std=gnuXY`/`-std=gnu++XY` mode.
> 
> Also, in non-GNU C23/C++11 mode, we can just suggest `[[gnu::format]]` instead

Switched to emitting `[[gnu::format]]` for C23/C++11, or `__attribute__((format))` in GNU modes. Otherwise the check is not performed.

Another possible issue is that clang supports the format attribute on non-variadic functions, which GCC doesn't. This diagnostic can suggest adding the attribute to such functions, which would cause an error when compiling with GCC. Should I just disable that case?

https://github.com/llvm/llvm-project/pull/166738


More information about the cfe-commits mailing list