https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94127
Bug ID: 94127 Summary: #pragma system_header marks unrelated files as system headers Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: aleksey.covacevice at gmail dot com Target Milestone: --- When compiling `x.c` as below: /* x.c */ #include <sys.h> #include <usr.h> /* sys.h */ #pragma GCC system_header #include "sys2.h" /* usr.h */ #include "other.h" /* sys2.h empty */ /* other.h empty */ file "other.h" gets marked as a system header, as per -fdebug-cpp: {P:./other.h;F:./usr.h;L:1;C:0;S:1;M:0x7f323a64b180;E:0,LOC:260288,R:260288} ^^^ This affects dependency generation with -MMD. If `sys.h` includes `<sys2.h>` (in angle brackets), or includes nothing at all, this does not happen. Neither does it happen if `x.c` includes either file with quotes. Nothing in the documentation suggests this behavior is intended.