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 |
| 5 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 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 | // |
| 9 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 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 | // |
| 14 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 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 |
| 23 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 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. |
| 32 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 33 | // RUN: -fmodule-file=%t/a.pcm \ |
| 34 | // RUN: -verify %s -DHAVE_A |
| 35 | // |
| 36 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 37 | // RUN: -fmodule-file=%t/a.pcm \ |
| 38 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 39 | // RUN: -verify %s -DHAVE_A |
| 40 | // |
| 41 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 42 | // RUN: -fmodule-file=%t/b.pcm \ |
| 43 | // RUN: -verify %s -DHAVE_A -DHAVE_B |
| 44 | // |
| 45 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 46 | // RUN: -fmodule-file=%t/a.pcm \ |
| 47 | // RUN: -fmodule-file=%t/b.pcm \ |
| 48 | // RUN: -verify %s -DHAVE_A -DHAVE_B |
| 49 | // |
| 50 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 51 | // RUN: -fmodule-file=%t/a.pcm \ |
| 52 | // RUN: -fmodule-file=%t/b.pcm \ |
| 53 | // RUN: -fmodule-file=%t/c.pcm \ |
| 54 | // RUN: -verify %s -DHAVE_A -DHAVE_B -DHAVE_C |
| 55 | // |
| 56 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 57 | // RUN: -I%S/Inputs/explicit-build \ |
| 58 | // RUN: -fmodule-file=%t/a.pcm \ |
| 59 | // RUN: -fmodule-file=%t/b.pcm \ |
| 60 | // RUN: -fmodule-file=%t/c.pcm \ |
| 61 | // RUN: -verify %s -INCLUDE_ALL -DHAVE_A -DHAVE_B -DHAVE_C |
| 62 | |
| 63 | #ifdef INCLUDE_ALL |
| 64 | #include "a.h" |
| 65 | #include "b.h" |
| 66 | #include "c.h" |
| 67 | static_assert(a == 1, ""); |
| 68 | static_assert(b == 2, ""); |
| 69 | static_assert(c == 3, ""); |
| 70 | #else |
| 71 | const int use_a = a; |
| 72 | #ifndef HAVE_A |
| 73 | // expected-error@-2 {{undeclared identifier}} |
| 74 | #else |
| 75 | // expected-error@-4 {{must be imported from module 'a'}} |
| 76 | // expected-note@Inputs/explicit-build/a.h:* {{here}} |
| 77 | #endif |
| 78 | |
| 79 | const int use_b = b; |
| 80 | #ifndef HAVE_B |
| 81 | // expected-error@-2 {{undeclared identifier}} |
| 82 | #else |
| 83 | // expected-error@-4 {{must be imported from module 'b'}} |
| 84 | // expected-note@Inputs/explicit-build/b.h:* {{here}} |
| 85 | #endif |
| 86 | |
| 87 | const int use_c = c; |
| 88 | #ifndef HAVE_C |
| 89 | // expected-error@-2 {{undeclared identifier}} |
| 90 | #else |
| 91 | // expected-error@-4 {{must be imported from module 'c'}} |
| 92 | // expected-note@Inputs/explicit-build/c.h:* {{here}} |
| 93 | #endif |
| 94 | #endif |
| 95 | |
| 96 | // ------------------------------- |
| 97 | // Check that we can use a mixture of implicit and explicit modules. |
| 98 | // RUN: not %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 99 | // RUN: -fmodule-file=%t/b-not-a.pcm \ |
| 100 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 101 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-A-AND-B-NO-A %s |
| 102 | |
| 103 | // ------------------------------- |
| 104 | // Check that mixing an implicit and explicit form of the 'a' module is rejected. |
| 105 | // RUN: not %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 106 | // RUN: -fmodule-file=%t/a.pcm \ |
| 107 | // RUN: -fmodule-file=%t/b-not-a.pcm \ |
| 108 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-A-AND-B-NO-A %s |
| 109 | // |
| 110 | // RUN: not %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 111 | // RUN: -fmodule-file=%t/a.pcm \ |
| 112 | // RUN: -fmodule-file=%t/b-not-a.pcm \ |
| 113 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 114 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-A-AND-B-NO-A %s |
| 115 | // |
| 116 | // FIXME: We should load module map files specified on the command line and |
| 117 | // module map files in include paths on demand to allow this, and possibly |
| 118 | // also the previous case. |
| 119 | // CHECK-A-AND-B-NO-A: fatal error: module 'a' {{.*}} is not defined in any loaded module map |
| 120 | |
| 121 | // ------------------------------- |
| 122 | // Try to use two different flavors of the 'a' module. |
| 123 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 124 | // RUN: -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a-alt.pcm \ |
| 125 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty |
| 126 | // |
| 127 | // RUN: not %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 128 | // RUN: -fmodule-file=%t/a.pcm \ |
| 129 | // RUN: -fmodule-file=%t/a-alt.pcm \ |
| 130 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 131 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s |
| 132 | // |
| 133 | // RUN: not %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 134 | // RUN: -fmodule-file=%t/a-alt.pcm \ |
| 135 | // RUN: -fmodule-file=%t/a.pcm \ |
| 136 | // RUN: -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \ |
| 137 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s |
| 138 | // |
| 139 | // CHECK-MULTIPLE-AS: error: module 'a' has already been loaded; cannot load module file '{{.*a(-alt)?}}.pcm' |
| 140 | |
| 141 | // ------------------------------- |
| 142 | // Try to import a PCH with -fmodule-file= |
| 143 | // RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 144 | // RUN: -fmodule-name=a -emit-pch %S/Inputs/explicit-build/a.h -o %t/a.pch \ |
| 145 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty |
| 146 | // |
| 147 | // RUN: not %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \ |
| 148 | // RUN: -fmodule-file=%t/a.pch \ |
| 149 | // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-A-AS-PCH %s |
| 150 | // |
| 151 | // CHECK-A-AS-PCH: fatal error: AST file '{{.*}}a.pch' was not built as a module |