xref: /aosp_15_r20/external/clang/test/Modules/no-implicit-builds.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: rm -rf %t
2*67e74705SXin Li 
3*67e74705SXin Li // RUN: %clang -x c++ -std=c++11 -fmodules -fno-implicit-modules /dev/null -### \
4*67e74705SXin Li // RUN:     2>&1 | FileCheck --check-prefix=CHECK-NO-MODULE-CACHE %s
5*67e74705SXin Li // CHECK-NO-MODULE-CACHE-NOT: -fmodules-cache-path
6*67e74705SXin Li 
7*67e74705SXin Li // Produce an error if a module is needed, but not found.
8*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
9*67e74705SXin Li // RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \
10*67e74705SXin Li // RUN:     -fno-implicit-modules %s -verify
11*67e74705SXin Li //
12*67e74705SXin Li // Same thing if we're running -cc1 and no module cache path has been provided.
13*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps \
14*67e74705SXin Li // RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \
15*67e74705SXin Li // RUN:     %s -verify
16*67e74705SXin Li 
17*67e74705SXin Li // Compile the module and put it into the cache.
18*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
19*67e74705SXin Li // RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \
20*67e74705SXin Li // RUN:     %s -Rmodule-build 2>&1 | FileCheck --check-prefix=CHECK-CACHE-BUILD %s
21*67e74705SXin Li // CHECK-CACHE-BUILD: {{building module 'b'}}
22*67e74705SXin Li 
23*67e74705SXin Li // Produce an error if a module is found in the cache but implicit modules is off.
24*67e74705SXin Li // Note that the command line must match the command line for the first check, otherwise
25*67e74705SXin Li // this check might not find the module in the cache and trivially succeed.
26*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
27*67e74705SXin Li // RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \
28*67e74705SXin Li // RUN:     %s -Rmodule-build -fno-implicit-modules -verify
29*67e74705SXin Li 
30*67e74705SXin Li // Verify that we can still pass the module via -fmodule-file when implicit modules
31*67e74705SXin Li // are switched off:
32*67e74705SXin Li // - First, explicitly compile the module:
33*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodule-name=b -o %t/b.pcm \
34*67e74705SXin Li // RUN:     -emit-module %S/Inputs/no-implicit-builds/b.modulemap \
35*67e74705SXin Li // RUN:     -fno-implicit-modules
36*67e74705SXin Li //
37*67e74705SXin Li // - Next, verify that we can load it:
38*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodule-file=%t/b.pcm \
39*67e74705SXin Li // RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \
40*67e74705SXin Li // RUN:     -fno-implicit-modules %s
41*67e74705SXin Li 
42*67e74705SXin Li #include "Inputs/no-implicit-builds/b.h"  // expected-error {{is needed but has not been provided}}
43