https://llvm.org/bugs/show_bug.cgi?id=26577

            Bug ID: 26577
           Summary: #include_next distinguish between double quotes and
                    angle brackets inclusion
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: lugovs...@gmail.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to