xref: /llvm-project/clang/test/CXX/module/basic/basic.search/module-import.cppm (revision d54888a3ebb141cdbb5e88ed7a3a2a54d24fc904)
1// Tests for imported module search.
2//
3// RUN: rm -rf %t
4// RUN: mkdir %t
5// RUN: split-file %s %t
6//
7// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm
8// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=%t/x.pcm %t/y.cppm -o %t/y.pcm
9//
10// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.pcm -verify %t/use.cpp \
11// RUN:            -DMODULE_NAME=x
12// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/y.pcm -verify %t/use.cpp \
13// RUN:            -DMODULE_NAME=y
14//
15// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x=%t/x.pcm -verify %t/use.cpp \
16// RUN:            -DMODULE_NAME=x
17// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=y=%t/y.pcm -verify %t/use.cpp \
18// RUN:            -DMODULE_NAME=y
19//
20// RUN: mv %t/x.pcm %t/a.pcm
21//
22// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \
23// RUN:            -DMODULE_NAME=x
24// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \
25// RUN:            -DMODULE_NAME=y
26// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \
27// RUN:            -DMODULE_NAME=y
28//
29// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm %t/z.cppm -o %t/z.pcm
30//
31// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=z=%t/z.pcm -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \
32// RUN:            -DMODULE_NAME=z
33//
34
35//--- x.cppm
36export module x;
37int a, b;
38
39//--- y.cppm
40export module y;
41import x;
42int c;
43
44//--- z.cppm
45export module z;
46import y;
47int d;
48
49//--- use.cpp
50import MODULE_NAME;
51
52// expected-no-diagnostics
53