38 lines · cpp
1// Tests referencing variable with initializer containing side effect across module boundary2//3// RUN: rm -rf %t4// RUN: mkdir -p %t5// RUN: split-file %s %t6 7// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/Foo.cppm \8// RUN: -o %t/Foo.pcm9 10// RUN: %clang_cc1 -std=c++20 -emit-module-interface \11// RUN: -fmodule-file=Foo=%t/Foo.pcm \12// RUN: %t/Bar.cppm \13// RUN: -o %t/Bar.pcm14 15// RUN: %clang_cc1 -std=c++20 -emit-obj \16// RUN: -main-file-name Bar.cppm \17// RUN: -fmodule-file=Foo=%t/Foo.pcm \18// RUN: -x pcm %t/Bar.pcm \19// RUN: -o %t/Bar.o20 21//--- Foo.cppm22export module Foo;23 24export {25class S {};26 27inline S s = S{};28}29 30//--- Bar.cppm31export module Bar;32import Foo;33 34S bar() {35 return s;36}37 38