<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - #include_next distinguish between double quotes and angle brackets inclusion"
   href="https://llvm.org/bugs/show_bug.cgi?id=26577">26577</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>#include_next distinguish between double quotes and angle brackets inclusion
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lugovskoy@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang preprocessor goes to infinite loop trying to resolve #include_next
directive.

According to GCC specification for #include_next extension (that is also known
as Wrapper Headers):

`#include_next' does not distinguish between <file> and "file" inclusion, nor
does it check that the file you specify has the same name as the current file.
It simply looks for the file named, starting with the directory in the search
path after the one where the current file was found.

At the same time clang preprocessor handles #include_next directives
differently if filenames are enclosed with double quotes and angle brackets.
Let's see the example:

'test.c':
#include "mystd.h"

'mystd.h':
#include_next "mystd.h"

'inc/mystd.h':
int a;

$gcc -E -Iinc test.c
...
int a;
...

$clang --version
clang version 3.7.1 (tags/RELEASE_371/final)

$clang -E -Iinc test.c
...
...
...
never ending infinite loop
...
...

clang preprocessor recursively includes 'mystd.h' header file


If 'mystd.h' is changed to enclose filename with angle brackets then clang
works fine:

'mystd.h':
#include_next <mystd.h>


$clang -E -Iinc test.c
...
int a;
...


Clang preprocessor should not depend on enclosing methods to process
#include_next directives.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>