https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84628
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The warning/error attributes have been added for purposes like glibc memset inline, which does: if (__builtin_constant_p (__len) && __len == 0 && (!__builtin_constant_p (__ch) || __ch != 0)) { __warn_memset_zero_len (); return __dest; } where __warn_memset_zero_len has the warning attribute. This only works if it is after optimization. If you want a diagnostics whenever you reference some function, you are looking for the deprecated attribute instead.