https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87730

            Bug ID: 87730
           Summary: Warn about misuses of __has_include_next
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
            Blocks: 87403
  Target Milestone: ---

Clang has some nice warnings for dubious uses of __has_include_next.

Given:

#if __has_include_next(</usr/include/stdio.h>)
#endif

In the main file being compiled this produces:

foo.cc:1:5: warning: #include_next in primary source file
[-Winclude-next-outside-header]
#if __has_include_next(</usr/include/stdio.h>)
    ^

and in an included header it produces:

In file included from foo.cc:1:
./foo.h:1:5: warning: #include_next with absolute path
[-Winclude-next-absolute-path]
#if __has_include_next(</usr/include/stdio.h>)
    ^


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning

Reply via email to