| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/lib.cppm -o %t/lib.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \ |
| 7 |
// RUN: -verify -fsyntax-only |
| 8 |
|
| 9 |
// Test again with reduced BMI |
| 10 |
// RUN: rm -rf %t |
| 11 |
// RUN: mkdir -p %t |
| 12 |
// RUN: split-file %s %t |
| 13 |
// |
| 14 |
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/lib.cppm -o %t/lib.pcm |
| 15 |
// RUN: %clang_cc1 -std=c++20 %t/main.cpp -fmodule-file=lib=%t/lib.pcm \ |
| 16 |
// RUN: -verify -fsyntax-only |
| 17 |
|
| 18 |
//--- header.h |
| 19 |
namespace lib::inline __1 { |
| 20 |
template <class> |
| 21 |
inline constexpr bool test = false; |
| 22 |
template <class> |
| 23 |
constexpr bool func() { |
| 24 |
return false; |
| 25 |
} |
| 26 |
inline constexpr bool non_templ = true; |
| 27 |
} // namespace lib |
| 28 |
|
| 29 |
//--- lib.cppm |
| 30 |
module; |
| 31 |
#include "header.h" |
| 32 |
export module lib; |
| 33 |
|
| 34 |
export namespace lib { |
| 35 |
using lib::test; |
| 36 |
using lib::func; |
| 37 |
using lib::non_templ; |
| 38 |
} // namespace lib |
| 39 |
|
| 40 |
//--- main.cpp |
| 41 |
// expected-no-diagnostics |
| 42 |
import lib; |
| 43 |
|
| 44 |
struct foo {}; |
| 45 |
|
| 46 |
template <> |
| 47 |
inline constexpr bool lib::test<foo> = true; |
| 48 |
|
| 49 |
template <> |
| 50 |
constexpr bool lib::func<foo>() { |
| 51 |
return true; |
| 52 |
} |
| 53 |
|
| 54 |
static_assert(lib::test<foo>); |
| 55 |
static_assert(lib::func<foo>()); |