1 // RUN: rm -rf %t 2 // RUN: mkdir %t 3 // RUN: echo 'extern int a; template<typename T> int a2 = T::error;' > %t/a.h 4 // RUN: echo 'extern int b;' > %t/b.h 5 // RUN: echo 'extern int c = 0;' > %t/c.h 6 // RUN: echo 'module a { header "a.h" header "b.h" header "c.h" }' > %t/modulemap 7 // RUN: echo 'module other {}' > %t/other.modulemap 8 9 // We lazily check that the files referenced by an explicitly-specified .pcm 10 // file exist. Test this by removing files and ensuring that the compilation 11 // still succeeds. 12 // 13 // RUN: %clang_cc1 -fmodules -I %t -emit-module -fmodule-name=a -x c++ %t/modulemap -o %t/a.pcm \ 14 // RUN: -fmodule-map-file=%t/other.modulemap \ 15 // RUN: -fmodules-embed-file=%t/modulemap -fmodules-embed-file=%t/other.modulemap 16 // RUN: %clang_cc1 -fmodules -I %t -emit-module -fmodule-name=a -x c++ %t/modulemap -o %t/b.pcm \ 17 // RUN: -fmodule-map-file=%t/other.modulemap \ 18 // RUN: -fmodules-embed-all-files 19 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s 20 // RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s 21 // RUN: rm %t/modulemap 22 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s 23 // RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s 24 // RUN: rm %t/other.modulemap 25 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s 26 // RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s 27 // RUN: sleep 1 28 // RUN: touch %t/a.h 29 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s 30 // RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s 31 // RUN: rm %t/b.h 32 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s 33 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/b.pcm %s 34 // RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s --check-prefix=MISSING-B 35 // RUN: rm %t/a.h 36 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -verify 37 // RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/b.pcm %s -verify 38 39 // Oftentimes on Windows there are open handles, and deletion will fail. 40 // REQUIRES: can-remove-opened-file 41 42 #include "a.h" // expected-error {{file not found}} 43 int x = b; 44 45 #ifdef ERRORS 46 int y = a2<int>; 47 // CHECK: In module 'a': 48 // CHECK-NEXT: a.h:1:45: error: 49 50 // MISSING-B: could not find file '{{.*}}b.h' 51 // MISSING-B-NOT: please delete the module cache 52 #endif 53 54 // RUN: not %clang_cc1 -fmodules -I %t -emit-module -fmodule-name=a -x c++ /dev/null -o %t/c.pcm \ 55 // RUN: -fmodules-embed-file=%t/does-not-exist 2>&1 | FileCheck %s --check-prefix=MISSING-EMBED 56 // MISSING-EMBED: fatal error: file '{{.*}}does-not-exist' specified by '-fmodules-embed-file=' not found 57