clang doesn't include two headers symlinked to the same target
| Bugzilla Link | 42500 |
| Version | 6.0 |
| OS | Linux |
| Attachments | Test program |
| CC | @zygoloid |
Extended Description
Hello,
My system is Fedora 28 with clang 6.0.1 installed as the clang-6.0.1-2.fc28.x86_64 package.
When compiling a C source file that includes two headers which are different symlinks to the same target, then the second header is not included.
The issue is reproduced by the attached test program:
$ tar xfz test.tar.gz $ cd test
$ tree --charset ascii
.
|-- a
| |-- linux.h
| -- platform.h -> ../platform.h |-- b | |-- linux.h | -- platform.h -> ../platform.h
|-- main.c
`-- platform.h
$ clang -I. main.c main.c:8:7: error: use of undeclared identifier 'B' r = B; ^ 1 error generated.
The only explanation why the macro B is not defined is that the header b/platform.h is not included.
Note that gcc compiles with no errors:
$ gcc -I. main.c $ ls a.out a.out
Also note that if to replace the b/platform.h symlink with its target then clang compiles with no errors either:
$ rm a.out b/platform.h $ cp platform.h b/ $ clang -I. main.c $ ls a.out a.out
Hi, this behavior is no longer observed on trunk and this issue can be closed.
hkumar@:/data/hkumar/test/header_symlinked/test$ cat main.c
#include "a/platform.h"
#include "b/platform.h"
#include <stdio.h>
int
main ()
{
int r = A;
printf("%d", r);
r = B;
printf("%d", r);
return r;
}
hkumar:/data/hkumar/test/header_symlinked/test$ ls
a a.out b main.c platform.h
hkumar:/data/hkumar/test/header_symlinked/test$ clang -I. main.c
hkumar:/data/hkumar/test/header_symlinked/test$ ./a.out
12
hkumar:/data/hkumar/test/header_symlinked/test$