| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// |
| 4 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm -fprebuilt-module-path=%t |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface -o %t/c.pcm -fprebuilt-module-path=%t |
| 7 |
// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -fsyntax-only -verify |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -fsyntax-only -verify -fexperimental-new-constant-interpreter |
| 9 |
|
| 10 |
//--- a.h |
| 11 |
template <typename T> |
| 12 |
struct A { |
| 13 |
static const T value0; |
| 14 |
static const T value1; |
| 15 |
|
| 16 |
constexpr T get0() { |
| 17 |
return value0; |
| 18 |
} |
| 19 |
|
| 20 |
constexpr T get1() { |
| 21 |
return value1; |
| 22 |
} |
| 23 |
}; |
| 24 |
|
| 25 |
template <typename T> |
| 26 |
const T A<T>::value0 = T(43); |
| 27 |
template <typename T> |
| 28 |
const T A<T>::value1 = T(44); |
| 29 |
|
| 30 |
//--- a.cppm |
| 31 |
module; |
| 32 |
#include "a.h" |
| 33 |
export module a; |
| 34 |
export using ::A; |
| 35 |
|
| 36 |
//--- b.cppm |
| 37 |
export module b; |
| 38 |
export import a; |
| 39 |
|
| 40 |
export constexpr int bar() { |
| 41 |
return A<int>().get0(); |
| 42 |
} |
| 43 |
|
| 44 |
//--- c.cppm |
| 45 |
export module c; |
| 46 |
export import b; |
| 47 |
|
| 48 |
export constexpr int foo() { |
| 49 |
return A<int>().get1() + A<int>().get0(); |
| 50 |
} |
| 51 |
|
| 52 |
//--- d.cpp |
| 53 |
// expected-no-diagnostics |
| 54 |
|
| 55 |
import c; |
| 56 |
|
| 57 |
static_assert(bar() + foo() == 130); |
| 58 |
|