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