llvm / llvm/llvm-project

Header-unit using declaration not visible.

Open
#160,218 3 comments 0 reactions 0 assignees View on GitHub
clang:modules
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Minimal Reproducer

B.hpp
```cpp
using INT = int;
```

A.hpp
```cpp
import "B.hpp";
```

file.cpp
```cpp
import "A.hpp"
INT a;
```

`clang.exe -std=c++2b -fmodule-header=user B.hpp -o B.pcm`
`clang.exe -std=c++2b -fmodule-file="B.pcm" -fmodule-header=user A.hpp -o A.pcm`
`clang.exe -std=c++2b -fmodule-file="B.pcm" -fmodule-file="A.pcm" -c file.cpp -o file.o`

Output:

```
file.cpp:1:1: warning: the implementation of header units is in an experimental phase [-Wexperimental-header-units]
1 | import "A.hpp";
| ^
file.cpp:2:1: error: declaration of 'INT' must be imported from module '.\B.hpp' before it is required
2 | INT a;
| ^
C:\Projects\llvm-project\llvm\cmake-build-debug\bin\B.hpp:1:7: note: declaration here is not visible
1 | using INT = int;
| ^
1 warning and 1 error generated.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.