| 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/a.cpp \ |
| 6 |
// RUN: -o %t/A.pcm |
| 7 |
|
| 8 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cpp \ |
| 9 |
// RUN: -fmodule-file=A=%t/A.pcm -o %t/B.pcm |
| 10 |
|
| 11 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/c.cpp \ |
| 12 |
// RUN: -fmodule-file=A=%t/A.pcm -o %t/C.pcm |
| 13 |
|
| 14 |
// RUN: %clang_cc1 -std=c++20 -verify %t/main.cpp \ |
| 15 |
// RUN: -fmodule-file=A=%t/A.pcm \ |
| 16 |
// RUN: -fmodule-file=B=%t/B.pcm \ |
| 17 |
// RUN: -fmodule-file=C=%t/C.pcm |
| 18 |
|
| 19 |
// expected-no-diagnostics |
| 20 |
|
| 21 |
//--- a.cpp |
| 22 |
|
| 23 |
export module A; |
| 24 |
export consteval const char *hello() { return "hello"; } |
| 25 |
export constexpr const char *helloA0 = hello(); |
| 26 |
export constexpr const char *helloA1 = helloA0; |
| 27 |
export constexpr const char *helloA2 = hello(); |
| 28 |
|
| 29 |
//--- b.cpp |
| 30 |
|
| 31 |
export module B; |
| 32 |
import A; |
| 33 |
export constexpr const char *helloB1 = helloA0; |
| 34 |
export constexpr const char *helloB2 = hello(); |
| 35 |
|
| 36 |
//--- c.cpp |
| 37 |
|
| 38 |
export module C; |
| 39 |
import A; |
| 40 |
export constexpr const char *helloC1 = helloA1; |
| 41 |
export constexpr const char *helloC2 = hello(); |
| 42 |
|
| 43 |
//--- main.cpp |
| 44 |
|
| 45 |
import A; |
| 46 |
import B; |
| 47 |
import C; |
| 48 |
|
| 49 |
// These are valid: they refer to the same evaluation of the same constant. |
| 50 |
static_assert(helloA0 == helloA1); |
| 51 |
static_assert(helloA0 == helloB1); |
| 52 |
static_assert(helloA0 == helloC1); |
| 53 |
|
| 54 |
// These refer to distinct evaluations, and so may or may not be equal. |
| 55 |
static_assert(helloA1 == helloA2); // expected-error {{}} expected-note {{unspecified value}} |
| 56 |
static_assert(helloA1 == helloB2); // expected-error {{}} expected-note {{unspecified value}} |
| 57 |
static_assert(helloA1 == helloC2); // expected-error {{}} expected-note {{unspecified value}} |
| 58 |
static_assert(helloA2 == helloB2); // expected-error {{}} expected-note {{unspecified value}} |
| 59 |
static_assert(helloA2 == helloC2); // expected-error {{}} expected-note {{unspecified value}} |
| 60 |
static_assert(helloB2 == helloC2); // expected-error {{}} expected-note {{unspecified value}} |