| 1 |
// https://github.com/llvm/llvm-project/issues/59780 |
| 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/data.cppm -emit-module-interface -o %t/data.pcm |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fprebuilt-module-path=%t -fsyntax-only -verify |
| 9 |
|
| 10 |
// RUN: %clang_cc1 -std=c++20 %t/data.cppm -emit-reduced-module-interface -o %t/data.pcm |
| 11 |
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fprebuilt-module-path=%t -fsyntax-only -verify |
| 12 |
|
| 13 |
//--- foo.h |
| 14 |
namespace std { |
| 15 |
|
| 16 |
template <class _Tp> |
| 17 |
class expected { |
| 18 |
public: |
| 19 |
expected(_Tp&& __u) |
| 20 |
{} |
| 21 |
|
| 22 |
constexpr ~expected() |
| 23 |
requires(__is_trivially_destructible(_Tp)) |
| 24 |
= default; |
| 25 |
|
| 26 |
constexpr ~expected() |
| 27 |
requires(!__is_trivially_destructible(_Tp)) |
| 28 |
{ |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
template <class _Tp> |
| 33 |
class unique_ptr { |
| 34 |
public: |
| 35 |
unique_ptr(void* __p) {} |
| 36 |
~unique_ptr() {} |
| 37 |
}; |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
//--- data.cppm |
| 42 |
module; |
| 43 |
#include "foo.h" |
| 44 |
export module data; |
| 45 |
export namespace std { |
| 46 |
using std::unique_ptr; |
| 47 |
using std::expected; |
| 48 |
} |
| 49 |
|
| 50 |
export std::expected<std::unique_ptr<int>> parse() { |
| 51 |
return std::unique_ptr<int>(nullptr); |
| 52 |
} |
| 53 |
|
| 54 |
//--- main.cpp |
| 55 |
// expected-no-diagnostics |
| 56 |
import data; |
| 57 |
|
| 58 |
int main(int argc, const char *argv[]) { |
| 59 |
std::expected<std::unique_ptr<int>> result = parse(); |
| 60 |
} |