| 1 |
// https://github.com/llvm/llvm-project/issues/54457 |
| 2 |
// |
| 3 |
// RUN: rm -rf %t |
| 4 |
// RUN: mkdir %t |
| 5 |
// RUN: split-file %s %t |
| 6 |
// |
| 7 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -verify -S -o - |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -verify -S -o - |
| 9 |
// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-module-interface -o %t/C.pcm |
| 10 |
// RUN: %clang_cc1 -std=c++20 %t/UseC.cppm -fprebuilt-module-path=%t -verify -S -o - |
| 11 |
|
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -o %t/C.pcm |
| 13 |
// RUN: %clang_cc1 -std=c++20 %t/UseC.cppm -fprebuilt-module-path=%t -verify -S -o - |
| 14 |
|
| 15 |
//--- A.cppm |
| 16 |
// expected-no-diagnostics |
| 17 |
export module A; |
| 18 |
|
| 19 |
export template<typename T> |
| 20 |
struct s { |
| 21 |
friend s f(s) { |
| 22 |
return s(); |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
void g() { |
| 27 |
f(s<int>()); |
| 28 |
} |
| 29 |
|
| 30 |
//--- B.cppm |
| 31 |
// expected-no-diagnostics |
| 32 |
export module B; |
| 33 |
|
| 34 |
export template<typename T> |
| 35 |
struct s { |
| 36 |
friend constexpr auto f(s) -> s { |
| 37 |
return s(); |
| 38 |
} |
| 39 |
}; |
| 40 |
|
| 41 |
void g() { |
| 42 |
constexpr auto first = f(s<int>()); |
| 43 |
} |
| 44 |
|
| 45 |
//--- C.cppm |
| 46 |
// expected-no-diagnostics |
| 47 |
export module C; |
| 48 |
|
| 49 |
export template<typename StandardCharT, int N> |
| 50 |
struct basic_symbol_text { |
| 51 |
template<int N2> |
| 52 |
constexpr friend basic_symbol_text operator+( |
| 53 |
const basic_symbol_text&, const basic_symbol_text<char, N2>&) noexcept |
| 54 |
{ |
| 55 |
return basic_symbol_text{}; |
| 56 |
} |
| 57 |
}; |
| 58 |
|
| 59 |
constexpr auto xxx = basic_symbol_text<char, 1>{} + basic_symbol_text<char, 1>{}; |
| 60 |
|
| 61 |
//--- UseC.cppm |
| 62 |
// expected-no-diagnostics |
| 63 |
import C; |
| 64 |
void foo() {} |