Bug 87730 - Warn about misuses of __has_include_next
Summary: Warn about misuses of __has_include_next
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 9.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: new-warning, new_warning
  Show dependency treegraph
 
Reported: 2018-10-24 13:08 UTC by Jonathan Wakely
Modified: 2021-12-20 08:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-12-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2018-10-24 13:08:05 UTC
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>)
    ^
Comment 1 Eric Gallager 2021-12-20 08:04:43 UTC
Confirmed.