https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112318
S. Davis Herring <herring at lanl dot gov> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |herring at lanl dot gov --- Comment #4 from S. Davis Herring <herring at lanl dot gov> --- The issue is really broader than just "declaration or use is not in -isystem"; since it's standard practice to use -isystem for third-party headers (to avoid "personal" warnings like -Wparentheses taking effect in code not written to them), this still fails to issue a warning if `foo` comes from such a header. (But the warning works when foo's author checks for it in their own unit tests...) It's a very hard problem in general. A colleague pointed me at Perl's carp, which attempts to identify whose "fault" a diagnostic is <https://perldoc.perl.org/Carp#DESCRIPTION>. The package rule there could even be applied to C++20 modules, or perhaps to top-level namespaces in a pinch. Beyond that, it might be worthwhile to presume that any warning triggered by a type- or value-dependent expression should be associated (for -Wsystem-headers purposes) with the point of instantiation, although I'm sure there would be some false positives from that. (There needs to be a better-than-#pragma way to suppress individual deprecation warnings for such cases.)