61 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4 5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cpp \6// RUN: -o %t/A.pcm7 8// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cpp \9// RUN: -fmodule-file=A=%t/A.pcm -o %t/B.pcm10 11// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/c.cpp \12// RUN: -fmodule-file=A=%t/A.pcm -o %t/C.pcm13 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.pcm18 19// expected-no-diagnostics20 21//--- a.cpp22 23export module A;24export consteval const char *hello() { return "hello"; }25export constexpr const char *helloA0 = hello();26export constexpr const char *helloA1 = helloA0;27export constexpr const char *helloA2 = hello();28 29//--- b.cpp30 31export module B;32import A;33export constexpr const char *helloB1 = helloA0;34export constexpr const char *helloB2 = hello();35 36//--- c.cpp37 38export module C;39import A;40export constexpr const char *helloC1 = helloA1;41export constexpr const char *helloC2 = hello();42 43//--- main.cpp44 45import A;46import B;47import C;48 49// These are valid: they refer to the same evaluation of the same constant.50static_assert(helloA0 == helloA1);51static_assert(helloA0 == helloB1);52static_assert(helloA0 == helloC1);53 54// These refer to distinct evaluations, and so may or may not be equal.55static_assert(helloA1 == helloA2); // expected-error {{}} expected-note {{unspecified value}}56static_assert(helloA1 == helloB2); // expected-error {{}} expected-note {{unspecified value}}57static_assert(helloA1 == helloC2); // expected-error {{}} expected-note {{unspecified value}}58static_assert(helloA2 == helloB2); // expected-error {{}} expected-note {{unspecified value}}59static_assert(helloA2 == helloC2); // expected-error {{}} expected-note {{unspecified value}}60static_assert(helloB2 == helloC2); // expected-error {{}} expected-note {{unspecified value}}61