1// It is annoying to handle different slash direction 2// in Windows and Linux. So we disable the test on Windows 3// here. 4// REQUIRES: !system-windows 5// On AIX, the default output for `-c` may be `.s` instead of `.o`, 6// which makes the test fail. So disable the test on AIX. 7// REQUIRES: !system-aix 8// 9// RUN: rm -rf %t 10// RUN: mkdir %t 11// RUN: split-file %s %t 12// 13// Tests that the .pcm file will be generated in the same directory with the specified 14// output and the name of the .pcm file should be the same with the input file. 15// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -c -o %t/output/Hello.o \ 16// RUN: -### 2>&1 | FileCheck %t/Hello.cppm 17// 18// Tests that the output file will be generated in the input directory if the output 19// file is not the corresponding object file. 20// RUN: %clang -std=c++20 %t/Hello.cppm %t/AnotherModule.cppm -fmodule-output -o \ 21// RUN: %t/output/a.out -### 2>&1 | FileCheck %t/AnotherModule.cppm 22// 23// Tests that clang will reject the command line if it specifies -fmodule-output with 24// multiple archs. 25// RUN: not %clang %t/Hello.cppm -fmodule-output -arch i386 -arch x86_64 -### \ 26// RUN: --target=x86_64-apple-darwin 2>&1 | FileCheck %t/Hello.cppm -check-prefix=MULTIPLE-ARCH 27 28// Tests that the .pcm file will be generated in the same path with the specified one 29// in the comamnd line. 30// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/pcm/Hello.pcm -o %t/Hello.o \ 31// RUN: -c -### 2>&1 | FileCheck %t/Hello.cppm --check-prefix=CHECK-SPECIFIED 32// 33// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output=%t/Hello.pcm -fmodule-output -c -fsyntax-only \ 34// RUN: -### 2>&1 | FileCheck %t/Hello.cppm --check-prefix=CHECK-NOT-USED 35 36// Test that we can emit a warning if the type of the input file is not a module interface unit. 37// RUN: %clang -std=c++20 %t/a.cpp -fmodule-output -c -o %t/a.o -### 2>&1 | FileCheck %t/a.cpp 38 39//--- Hello.cppm 40export module Hello; 41 42// CHECK: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/output/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm" 43// CHECK: "-emit-obj" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/output/Hello.o" "-x" "pcm" "{{.*}}/output/Hello.pcm" 44 45// MULTIPLE-ARCH: option '-fmodule-output' cannot be used with multiple arch options 46 47// CHECK-SPECIFIED: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/pcm/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm" 48// CHECK-SPECIFIED: "-emit-obj" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello.o" "-x" "pcm" "{{.*}}/pcm/Hello.pcm" 49 50// CHECK-NOT-USED-NOT: warning: argument unused during compilation: '-fmodule-output' 51// CHECK-NOT-USED-NOT: warning: argument unused during compilation: '-fmodule-output=Hello.pcm' 52// CHECK-NOT-USED-NOT: "-fmodule-output" 53// CHECK-NOT-USED-NOT: "-fmodule-output=" 54 55//--- AnotherModule.cppm 56export module AnotherModule; 57// CHECK: "-emit-module-interface" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello.pcm" "-x" "c++" "{{.*}}/Hello.cppm" 58// CHECK: "-emit-obj" {{.*}}"-main-file-name" "Hello.cppm" {{.*}}"-o" "{{.*}}/Hello-{{.*}}.o" "-x" "pcm" "{{.*}}/Hello.pcm" 59// CHECK: "-emit-module-interface" {{.*}}"-main-file-name" "AnotherModule.cppm" {{.*}}"-o" "{{.*}}/AnotherModule.pcm" "-x" "c++" "{{.*}}/AnotherModule.cppm" 60// CHECK: "-emit-obj" {{.*}}"-main-file-name" "AnotherModule.cppm" {{.*}}"-o" "{{.*}}/AnotherModule-{{.*}}.o" "-x" "pcm" "{{.*}}/AnotherModule.pcm" 61 62//--- a.cpp 63export module a; 64 65// CHECK: warning: argument unused during compilation: '-fmodule-output' 66