Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++ Modules] Exporting Redeclaration within language linkage #98583

Closed
ChuanqiXu9 opened this issue Jul 12, 2024 · 1 comment
Closed

[C++ Modules] Exporting Redeclaration within language linkage #98583

ChuanqiXu9 opened this issue Jul 12, 2024 · 1 comment
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@ChuanqiXu9
Copy link
Member

ChuanqiXu9 commented Jul 12, 2024

This is discussed in WG21's mailing list. Although this is not formally merged into the standard, I think it is fine to work on it already.

Reproducer:

export module mod;
extern "C++" void func();
export extern "C++" {
    void func();
}

Clang now will reject it due to [module.intefcae] p6. But we think the rejection may not be necessary. Since the intention of [module.intefcae] p6 is to avoid the name conflicting. But the entities in language linkage are always attached to global module. So we don't need to worry about the name conflicting here.

And both MSVC and GCC accept it: https://godbolt.org/z/74sTe4nP6

@ChuanqiXu9 ChuanqiXu9 added the clang:modules C++20 modules and Clang Header Modules label Jul 12, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 12, 2024

@llvm/issue-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)

This is discussed in WG21's mailing list. Although this is not formally merged into the standard, I think it is fine to work on it already.

Reproducer:

export module mod;
extern "C++" void func();
export extern "C++" {
    void func();
}

Clang now will reject it due to [[module.intefcae] p6](https://eel.is/c++draft/module.interface#6). But we think the rejection may not be necessary. Since the intention of [[module.intefcae] p6](https://eel.is/c++draft/module.interface#6) is to avoid the name conflicting. But the entities in language linkage are always attached to global module. So we don't need to worry about the name conflicting here.

aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this issue Jul 14, 2024
Close llvm#98583

Currently, clang will reject the following code:

```
export module mod;
extern "C++" void func();
export extern "C++" {
    void func();
}
```

while both MSVC and GCC accept it. Although clang's behavior matches the
current wording, from the discussion, the consensus is that we should
accept the above example from the intention. Since the intention to not
allow export redeclaration which is not exported is to make the linkage
clear. But it doesn't matter with the declarations within global module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

2 participants