https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69126
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #13 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > For whatever reason, the DECL_SOURCE_LOCATION of the x decl when it comes > from macro is the locus where the macro is used rather than the locus in the > macro. The actual issue is that "GCC diagnostic" uses the location passed to the diagnostic function explicitly (or input_location), never the location set by '+'. That is, warning("%q+D") uses input_location for testing against the pragma but DECL_SOURCE_LOCATION for reporting the warning. Of course, such behaviour breaks other cases, which is one reason to avoid '+'.