Debian Codegraph @

clang/test/Modules/pr170235.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4
5 // RUN: %clang_cc1 -std=c++20 %t/lib.cppm -emit-module-interface -o %t/lib.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm -fsyntax-only -verify
7 //
8 // RUN: %clang_cc1 -std=c++20 %t/lib.cppm -emit-reduced-module-interface -o %t/lib.pcm
9 // RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm -fsyntax-only -verify
10
11 //--- lib.cppm
12 export module lib;
13 namespace lib {
14 struct A;
15 // Definition comes BEFORE the class declaration
16 int foo(const A &, int) { return 42; }
17
18 struct A {
19 // Friend declaration inside the class
20 friend int foo(const A &, int);
21 };
22
23 export A a{};
24 }
25 //--- main.cpp
26 // expected-no-diagnostics
27 import lib;
28 int main() {
29 // Should be found via ADL since lib::a is of type lib::A
30 auto res1 = foo(lib::a, 1);
31 return 0;
32 }