Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
| 2 | |
| 3 | // ------------------------------- |
| 4 | // Build chained modules A, B, and C |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 5 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 6 | // RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a.pcm \ |
| 7 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty |
| 8 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 9 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 10 | // RUN: -fmodule-file=%t/a.pcm \ |
| 11 | // RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b.pcm \ |
| 12 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty |
| 13 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 14 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 15 | // RUN: -fmodule-file=%t/b.pcm \ |
| 16 | // RUN: -fmodule-name=c -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/c.pcm \ |
| 17 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty |
| 18 | // |
| 19 | // CHECK-NO-IMPLICIT-BUILD-NOT: building module |
| 20 | |
| 21 | // ------------------------------- |
| 22 | // Build B with an implicit build of A |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 23 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 24 | // RUN: -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b-not-a.pcm \ |
| 25 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-B-NO-A %s |
| 26 | // |
| 27 | // CHECK-B-NO-A: While building module 'b': |
| 28 | // CHECK-B-NO-A: building module 'a' as |
| 29 | |
| 30 | // ------------------------------- |
| 31 | // Check that we can use the explicitly-built A, B, and C modules. |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 32 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 33 | // RUN: -I%S/Inputs/explicit-build \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 34 | // RUN: -fmodule-file=%t/a.pcm \ |
| 35 | // RUN: -verify %s -DHAVE_A |
| 36 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 37 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 38 | // RUN: -I%S/Inputs/explicit-build \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 39 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 40 | // RUN: -fmodule-file=%t/a.pcm \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 41 | // RUN: -verify %s -DHAVE_A |
| 42 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 43 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 44 | // RUN: -I%S/Inputs/explicit-build \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 45 | // RUN: -fmodule-file=%t/b.pcm \ |
| 46 | // RUN: -verify %s -DHAVE_A -DHAVE_B |
| 47 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 48 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 49 | // RUN: -I%S/Inputs/explicit-build \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 50 | // RUN: -fmodule-file=%t/a.pcm \ |
| 51 | // RUN: -fmodule-file=%t/b.pcm \ |
| 52 | // RUN: -verify %s -DHAVE_A -DHAVE_B |
| 53 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 54 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 55 | // RUN: -I%S/Inputs/explicit-build \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 56 | // RUN: -fmodule-file=%t/a.pcm \ |
| 57 | // RUN: -fmodule-file=%t/b.pcm \ |
| 58 | // RUN: -fmodule-file=%t/c.pcm \ |
| 59 | // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C |
| 60 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 61 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 62 | // RUN: -I%S/Inputs/explicit-build \ |
| 63 | // RUN: -fmodule-file=%t/a.pcm \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 64 | // RUN: -fmodule-file=%t/c.pcm \ |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 65 | // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 66 | |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 67 | #if HAVE_A |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 68 | #include "a.h" |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 69 | static_assert(a == 1, ""); |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 70 | #else |
| 71 | const int use_a = a; // expected-error {{undeclared identifier}} |
| 72 | #endif |
| 73 | |
| 74 | #if HAVE_B |
| 75 | #include "b.h" |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 76 | static_assert(b == 2, ""); |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 77 | #else |
| 78 | const int use_b = b; // expected-error {{undeclared identifier}} |
| 79 | #endif |
| 80 | |
| 81 | #if HAVE_C |
| 82 | #include "c.h" |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 83 | static_assert(c == 3, ""); |
| 84 | #else |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 85 | const int use_c = c; // expected-error {{undeclared identifier}} |
| 86 | #endif |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 87 | |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 88 | #if HAVE_A && HAVE_B && HAVE_C |
| 89 | // expected-no-diagnostics |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
| 92 | // ------------------------------- |
| 93 | // Check that we can use a mixture of implicit and explicit modules. |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 94 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 95 | // RUN: -I%S/Inputs/explicit-build \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 96 | // RUN: -fmodule-file=%t/b-not-a.pcm \ |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 97 | // RUN: -verify %s -DHAVE_A -DHAVE_B |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 98 | |
| 99 | // ------------------------------- |
| 100 | // Try to use two different flavors of the 'a' module. |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 101 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 102 | // RUN: -fmodule-file=%t/a.pcm \ |
| 103 | // RUN: -fmodule-file=%t/b-not-a.pcm \ |
| 104 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s |
| 105 | // |
| 106 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 107 | // RUN: -fmodule-file=%t/a.pcm \ |
| 108 | // RUN: -fmodule-file=%t/b-not-a.pcm \ |
| 109 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 110 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s |
| 111 | // |
| 112 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 113 | // RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a-alt.pcm \ |
| 114 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty |
| 115 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 116 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 117 | // RUN: -fmodule-file=%t/a.pcm \ |
| 118 | // RUN: -fmodule-file=%t/a-alt.pcm \ |
| 119 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 120 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s |
| 121 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 122 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 123 | // RUN: -fmodule-file=%t/a-alt.pcm \ |
| 124 | // RUN: -fmodule-file=%t/a.pcm \ |
| 125 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 126 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s |
| 127 | // |
NAKAMURA Takumi | 314df7a | 2014-10-28 11:34:29 +0000 | [diff] [blame] | 128 | // CHECK-MULTIPLE-AS: error: module 'a' is defined in both '{{.*}}/a{{.*}}.pcm' and '{{.*[/\\]}}a{{.*}}.pcm' |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 129 | |
| 130 | // ------------------------------- |
| 131 | // Try to import a PCH with -fmodule-file= |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 132 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 133 | // RUN: -fmodule-name=a -emit-pch %S/Inputs/explicit-build/a.h -o %t/a.pch \ |
| 134 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty |
| 135 | // |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 136 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
Richard Smith | e842a47 | 2014-10-22 02:05:46 +0000 | [diff] [blame] | 137 | // RUN: -fmodule-file=%t/a.pch \ |
| 138 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-A-AS-PCH %s |
| 139 | // |
| 140 | // CHECK-A-AS-PCH: fatal error: AST file '{{.*}}a.pch' was not built as a module |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 141 | |
| 142 | // ------------------------------- |
| 143 | // Try to import a non-AST file with -fmodule-file= |
| 144 | // |
| 145 | // RUN: touch %t/not.pcm |
| 146 | // |
| 147 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 148 | // RUN: -fmodule-file=%t/not.pcm \ |
| 149 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s |
| 150 | // |
Richard Smith | 37bd29a | 2015-02-28 03:09:52 +0000 | [diff] [blame^] | 151 | // CHECK-BAD-FILE: fatal error: file '{{.*}}not.pcm' is not a valid precompiled module file |
| 152 | |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 153 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 154 | // RUN: -fmodule-file=%t/nonexistent.pcm \ |
Richard Smith | 37bd29a | 2015-02-28 03:09:52 +0000 | [diff] [blame^] | 155 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-FILE %s |
Richard Smith | d4b230b | 2014-10-27 23:01:16 +0000 | [diff] [blame] | 156 | // |
Richard Smith | 37bd29a | 2015-02-28 03:09:52 +0000 | [diff] [blame^] | 157 | // CHECK-NO-FILE: fatal error: module file '{{.*}}nonexistent.pcm' not found |
| 158 | |
| 159 | // RUN: mv %t/a.pcm %t/a-tmp.pcm |
| 160 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 161 | // RUN: -I%S/Inputs/explicit-build \ |
| 162 | // RUN: -fmodule-file=%t/c.pcm \ |
| 163 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-FILE-INDIRECT %s |
| 164 | // RUN: mv %t/a-tmp.pcm %t/a.pcm |
| 165 | // |
| 166 | // CHECK-NO-FILE-INDIRECT: error: module file '{{.*}}a.pcm' not found |
| 167 | // CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'b' in '{{.*}}b.pcm' |
| 168 | // CHECK-NO-FILE-INDIRECT-NEXT: note: imported by module 'c' in '{{.*}}c.pcm' |
Richard Smith | 5b39075 | 2014-11-21 05:37:20 +0000 | [diff] [blame] | 169 | |
| 170 | // ------------------------------- |
| 171 | // Check that we don't get upset if B's timestamp is newer than C's. |
| 172 | // RUN: touch %t/b.pcm |
| 173 | // |
| 174 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 175 | // RUN: -I%S/Inputs/explicit-build \ |
| 176 | // RUN: -fmodule-file=%t/c.pcm \ |
| 177 | // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C |
| 178 | // |
| 179 | // ... but that we do get upset if our B is different from the B that C expects. |
| 180 | // |
| 181 | // RUN: cp %t/b-not-a.pcm %t/b.pcm |
| 182 | // |
| 183 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 184 | // RUN: -I%S/Inputs/explicit-build \ |
| 185 | // RUN: -fmodule-file=%t/c.pcm \ |
| 186 | // RUN: %s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s |
| 187 | // |
| 188 | // CHECK-MISMATCHED-B: fatal error: malformed or corrupted AST file: {{.*}}b.pcm": module file out of date |