-
Couldn't load subscription status.
- Fork 15k
Closed
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules
Milestone
Description
When I have a template class in the global module fragment with a template class friend, and the class is instantiated inside a module, the friend declaration of the class appears to get attached to the module. This results in an error if two such modules (or module fragments) do this and one imports the other.
Reproducer (on godbolt: https://godbolt.org/z/61hTx776G):
// test.h
template<typename T>
struct Test {
template<typename U>
friend class Test;
};
// module1.cppm
module;
#include "test.h"
export module module1;
export void f1(Test<int>) {}
// module2.cppm
module;
#include "test.h"
export module module2;
import module1;
export void f2(Test<float>) {}yields
In module 'module1' imported from /app/module2.cppm:4:
test.h:4:16: error: declaration 'Test' attached to named module 'module1' cannot be attached to other modules
4 | friend class Test;
| ^
test.h:2:8: note: also found
2 | struct Test {
| ^
Metadata
Metadata
Assignees
Labels
clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Modules
Type
Projects
Status
Done