Clang Project

clang_source_code/test/CXX/modules-ts/basic/basic.search/module-import.cpp
1// Tests for imported module search.
2//
3// RUN: rm -rf %t
4// RUN: mkdir -p %t
5// RUN: echo 'export module x; int a, b;' > %t/x.cppm
6// RUN: echo 'export module y; import x; int c;' > %t/y.cppm
7// RUN: echo 'export module z; import y; int d;' > %t/z.cppm
8//
9// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm
10// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/y.cppm -o %t/y.pcm
11//
12// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.pcm -verify %s \
13// RUN:            -DMODULE_NAME=x
14// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -verify %s \
15// RUN:            -DMODULE_NAME=y
16//
17// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/x.pcm -verify %s \
18// RUN:            -DMODULE_NAME=x
19// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -verify %s \
20// RUN:            -DMODULE_NAME=y
21//
22// RUN: mv %t/x.pcm %t/a.pcm
23//
24// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/a.pcm -verify %s \
25// RUN:            -DMODULE_NAME=x
26// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
27// RUN:            -DMODULE_NAME=y
28// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
29// RUN:            -DMODULE_NAME=y
30//
31// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm %t/z.cppm -o %t/z.pcm
32//
33// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=z=%t/z.pcm -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \
34// RUN:            -DMODULE_NAME=z
35//
36
37import MODULE_NAME;
38
39// expected-no-diagnostics
40