aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Modules/pr170235.cppm
blob: 614c3abce3d61c662daa93ba09db4eac9e71d782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t

// RUN: %clang_cc1 -std=c++20 %t/lib.cppm -emit-module-interface -o %t/lib.pcm
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm -fsyntax-only -verify
//
// RUN: %clang_cc1 -std=c++20 %t/lib.cppm -emit-reduced-module-interface -o %t/lib.pcm
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm -fsyntax-only -verify

//--- lib.cppm
export module lib;
namespace lib {
    struct A;
    // Definition comes BEFORE the class declaration
    int foo(const A &, int) { return 42; }

    struct A {
        // Friend declaration inside the class
        friend int foo(const A &, int);
    };

    export A a{};
}
//--- main.cpp
// expected-no-diagnostics
import lib;
int main() {
    // Should be found via ADL since lib::a is of type lib::A
    auto res1 = foo(lib::a, 1); 
    return 0;
}