llvm-project/clang/test/Modules/no-implicit-std-cxx-module.cppm
Chuanqi Xu 807aa26136 [C++20] [Modules] Don't ignore -fmodule-file when we compile pcm files
Close https://github.com/llvm/llvm-project/issues/62843.

Previously when we compile .pcm files into .o files, the
`-fmodule-file=<module-name>=<module-path>` option is ignored. This is
conflicted with our consensus in
https://github.com/llvm/llvm-project/issues/62707.
2023-05-23 14:22:01 +08:00

55 lines
1.7 KiB
C++

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: cd %t
//
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -o %t/b.pcm
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -fmodule-file=b=%t/b.pcm \
// RUN: -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/user.cpp -fmodule-file=a=%t/a.pcm -verify -fsyntax-only
// RUN: %clang_cc1 -std=c++20 %t/user.cpp -fmodule-file=a=%t/a.pcm -verify -fsyntax-only \
// RUN: -Wno-read-modules-implicitly -DNO_DIAG
// RUN: %clang_cc1 -std=c++20 %t/user.cpp -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \
// RUN: -DNO_DIAG -verify -fsyntax-only
//
// RUN: %clang_cc1 -std=c++20 %t/a.pcm -S -emit-llvm -o - 2>&1 | FileCheck %t/a.cppm
// RUN: %clang_cc1 -std=c++20 %t/a.pcm -fmodule-file=b=%t/b.pcm -S -emit-llvm -o - 2>&1 \
// RUN: | FileCheck %t/a.cppm -check-prefix=CHECK-CORRECT
//
// RUN: mkdir -p %t/tmp
// RUN: mv %t/b.pcm %t/tmp/b.pcm
// RUN: not %clang_cc1 -std=c++20 %t/a.pcm -S -emit-llvm -o - 2>&1 \
// RUN: | FileCheck %t/a.cppm -check-prefix=CHECK-ERROR
// RUN: %clang_cc1 -std=c++20 %t/a.pcm -S -emit-llvm -o - 2>&1 -fmodule-file=b=%t/tmp/b.pcm \
// RUN: | FileCheck %t/a.cppm -check-prefix=CHECK-CORRECT
//--- b.cppm
export module b;
export int b() {
return 43;
}
//--- a.cppm
export module a;
import b;
export int a() {
return b() + 43;
}
// CHECK: it is deprecated to read module 'b' implcitly;
// CHECK-CORRECT-NOT: warning
// CHECK-CORRECT-NOT: error
// CHECK-ERROR: error: module file{{.*}}not found: module file not found
//--- user.cpp
#ifdef NO_DIAG
// expected-no-diagnostics
#else
// expected-warning@+2 {{it is deprecated to read module 'b' implcitly;}}
#endif
import a;
int use() {
return a();
}