| 1 |
// Test case from https://github.com/llvm/llvm-project/issues/60036 |
| 2 |
// |
| 3 |
// RUN: rm -rf %t |
| 4 |
// RUN: mkdir -p %t |
| 5 |
// RUN: split-file %s %t |
| 6 |
// |
| 7 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/b.pcm |
| 9 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm |
| 10 |
// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/d.pcm |
| 11 |
// RUN: %clang_cc1 -std=c++20 %t/e.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/e.pcm |
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/f.pcm |
| 13 |
// RUN: %clang_cc1 -std=c++20 %t/g.cppm -fprebuilt-module-path=%t -verify -fsyntax-only |
| 14 |
// |
| 15 |
// Tests that the behavior is fine with specifying module file with `-fmodule-file`. |
| 16 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm |
| 17 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/b.pcm |
| 18 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -o %t/c.pcm |
| 19 |
// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -o %t/d.pcm |
| 20 |
// RUN: %clang_cc1 -std=c++20 %t/e.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ |
| 21 |
// RUN: -fmodule-file=c=%t/c.pcm -fmodule-file=d=%t/d.pcm -o %t/e.pcm |
| 22 |
// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-module-interface -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm -fmodule-file=c=%t/c.pcm -fmodule-file=d=%t/d.pcm -o %t/f.pcm |
| 23 |
// RUN: %clang_cc1 -std=c++20 %t/g.cppm -fmodule-file=a=%t/a.pcm -fmodule-file=b=%t/b.pcm \ |
| 24 |
// RUN: -fmodule-file=c=%t/c.pcm -fmodule-file=d=%t/d.pcm -fmodule-file=e=%t/e.pcm \ |
| 25 |
// RUN: -fmodule-file=f=%t/f.pcm -verify -fsyntax-only |
| 26 |
|
| 27 |
// Test again with reduced BMI |
| 28 |
// RUN: rm -rf %t |
| 29 |
// RUN: mkdir -p %t |
| 30 |
// RUN: split-file %s %t |
| 31 |
// |
| 32 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm |
| 33 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/b.pcm |
| 34 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/c.pcm |
| 35 |
// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/d.pcm |
| 36 |
// RUN: %clang_cc1 -std=c++20 %t/e.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/e.pcm |
| 37 |
// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/f.pcm |
| 38 |
// RUN: %clang_cc1 -std=c++20 %t/g.cppm -fprebuilt-module-path=%t -verify -fsyntax-only |
| 39 |
|
| 40 |
|
| 41 |
//--- a.cppm |
| 42 |
export module a; |
| 43 |
|
| 44 |
export template<typename> |
| 45 |
struct a; |
| 46 |
|
| 47 |
template<typename T> |
| 48 |
struct a<T &> { |
| 49 |
using type = char; |
| 50 |
}; |
| 51 |
|
| 52 |
//--- b.cppm |
| 53 |
export module b; |
| 54 |
|
| 55 |
import a; |
| 56 |
|
| 57 |
typename a<char &>::type; |
| 58 |
|
| 59 |
//--- c.cppm |
| 60 |
export module c; |
| 61 |
|
| 62 |
import a; |
| 63 |
|
| 64 |
typename a<char &>::type; |
| 65 |
|
| 66 |
//--- d.cppm |
| 67 |
export module d; |
| 68 |
|
| 69 |
export template<typename> |
| 70 |
struct d { |
| 71 |
d() {} |
| 72 |
explicit d(int) requires(true) {} |
| 73 |
d(auto &&) {} |
| 74 |
}; |
| 75 |
|
| 76 |
//--- e.cppm |
| 77 |
export module e; |
| 78 |
|
| 79 |
import d; |
| 80 |
|
| 81 |
auto r = d<int>(); |
| 82 |
|
| 83 |
//--- f.cppm |
| 84 |
export module f; |
| 85 |
|
| 86 |
import a; |
| 87 |
import b; |
| 88 |
import c; |
| 89 |
import d; |
| 90 |
|
| 91 |
template<typename T> |
| 92 |
struct array { |
| 93 |
friend void fr(array<T> const &) { |
| 94 |
} |
| 95 |
}; |
| 96 |
|
| 97 |
array() -> array<typename a<char &>::type>; |
| 98 |
|
| 99 |
struct wrap { |
| 100 |
d<int> m; |
| 101 |
}; |
| 102 |
|
| 103 |
template<typename T> |
| 104 |
int f1(T) { |
| 105 |
return 1; |
| 106 |
} |
| 107 |
|
| 108 |
void f2() { |
| 109 |
d<int> view; |
| 110 |
int x = f1(view); |
| 111 |
typename a<decltype([x]{}) &>::type; |
| 112 |
wrap w; |
| 113 |
} |
| 114 |
|
| 115 |
//--- g.cppm |
| 116 |
// expected-no-diagnostics |
| 117 |
export module g; |
| 118 |
|
| 119 |
import e; |
| 120 |
import f; |