Close https://github.com/llvm/llvm-project/issues/159424 Close https://github.com/llvm/llvm-project/issues/133720 For in-class friend declaration, it is hard for the serializer to decide if they are visible to other modules. But luckily, Sema can handle it perfectly enough. So it is fine to make all of the in-class friend declaration as generally visible in ASTWriter and let the Sema to make the final call. This is safe as long as the corresponding class's visibility are correct.
32 lines
564 B
C++
32 lines
564 B
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
|
|
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
|
|
|
|
//--- a.cppm
|
|
export module a;
|
|
|
|
struct Base {
|
|
template <class T>
|
|
friend constexpr auto f(T) { return 0; }
|
|
};
|
|
export struct A: Base {};
|
|
|
|
//--- b.cppm
|
|
export module b;
|
|
|
|
import a;
|
|
|
|
namespace n {
|
|
|
|
struct B {};
|
|
|
|
auto b() -> void {
|
|
f(A{});
|
|
f(B{}); // expected-error {{use of undeclared identifier 'f'}}
|
|
}
|
|
|
|
} // namespace n
|