blob: ebe08fb40eb74996020382af8fb97001d48b4f0c [file] [log] [blame]
Richard Smith0f99d6a2015-08-09 08:48:41 +00001// RUN: rm -rf %t
2// RUN: mkdir %t
Richard Smithfb1e7f72015-08-14 05:02:58 +00003// 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
Richard Smith0f99d6a2015-08-09 08:48:41 +00008
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//
Richard Smithfb1e7f72015-08-14 05:02:58 +000013// 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
Richard Smith919ce232015-11-24 04:22:21 +000016// 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
Richard Smith0f99d6a2015-08-09 08:48:41 +000019// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s
Richard Smitha24ff552015-08-11 00:05:21 +000020// RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s
Richard Smith58df3432016-04-12 19:58:30 +000021// RUN: mv %t/modulemap %t/modulemap.moved
Richard Smith0f99d6a2015-08-09 08:48:41 +000022// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s
Richard Smitha24ff552015-08-11 00:05:21 +000023// RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s
Richard Smithfb1e7f72015-08-14 05:02:58 +000024// 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
Richard Smithe75ee0f2015-08-17 07:13:32 +000027// 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
Richard Smith0f99d6a2015-08-09 08:48:41 +000031// RUN: rm %t/b.h
32// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s
Richard Smith919ce232015-11-24 04:22:21 +000033// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/b.pcm %s
Richard Smitha24ff552015-08-11 00:05:21 +000034// RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -DERRORS 2>&1 | FileCheck %s --check-prefix=MISSING-B
Richard Smith58df3432016-04-12 19:58:30 +000035// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm -fmodule-map-file=%t/modulemap.moved %s
36// RUN: not %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm -fmodule-map-file=%t/modulemap.moved -std=c++1z %s
37// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm -fmodule-map-file=%t/modulemap.moved -std=c++1z -Wno-module-file-config-mismatch %s -Db=a
Richard Smith0f99d6a2015-08-09 08:48:41 +000038// RUN: rm %t/a.h
39// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/a.pcm %s -verify
Richard Smith919ce232015-11-24 04:22:21 +000040// RUN: %clang_cc1 -fmodules -I %t -fmodule-file=%t/b.pcm %s -verify
Richard Smith0f99d6a2015-08-09 08:48:41 +000041
Reid Kleckner397a17b2015-08-14 19:03:02 +000042// Oftentimes on Windows there are open handles, and deletion will fail.
43// REQUIRES: can-remove-opened-file
44
Richard Smith0f99d6a2015-08-09 08:48:41 +000045#include "a.h" // expected-error {{file not found}}
46int x = b;
Richard Smitha24ff552015-08-11 00:05:21 +000047
48#ifdef ERRORS
Richard Smithfb1e7f72015-08-14 05:02:58 +000049int y = a2<int>;
Richard Smitha24ff552015-08-11 00:05:21 +000050// CHECK: In module 'a':
Richard Smithfb1e7f72015-08-14 05:02:58 +000051// CHECK-NEXT: a.h:1:45: error:
Richard Smitha24ff552015-08-11 00:05:21 +000052
53// MISSING-B: could not find file '{{.*}}b.h'
Richard Smithd61c1f82015-08-11 00:32:42 +000054// MISSING-B-NOT: please delete the module cache
Richard Smitha24ff552015-08-11 00:05:21 +000055#endif
Richard Smithfb1e7f72015-08-14 05:02:58 +000056
Richard Smith919ce232015-11-24 04:22:21 +000057// RUN: not %clang_cc1 -fmodules -I %t -emit-module -fmodule-name=a -x c++ /dev/null -o %t/c.pcm \
Richard Smithfb1e7f72015-08-14 05:02:58 +000058// RUN: -fmodules-embed-file=%t/does-not-exist 2>&1 | FileCheck %s --check-prefix=MISSING-EMBED
59// MISSING-EMBED: fatal error: file '{{.*}}does-not-exist' specified by '-fmodules-embed-file=' not found