https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93739
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #1) > template<typename T> > [[gnu::warning("your type here")]] > bool print_type() { return true; } > > int i; > bool b = print_type<int>(); Oops, that was meant to be print_type<decltype(i)>() The output is: warn.cc: In function ‘void __static_initialization_and_destruction_0(int, int)’: warn.cc:6:33: warning: call to ‘print_type<int>’ declared with attribute warning: your type here [-Wattribute-warning] 6 | bool b = print_type<decltype(i)>(); | ~~~~~~~~~~~~~~~~~~~~~~~^~