| 1 |
// https://github.com/llvm/llvm-project/issues/60775 |
| 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 -I%t -emit-module-interface -o %t/a.pcm |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/b.cpp -fmodule-file=a=%t/a.pcm -verify -fsyntax-only |
| 9 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -I%t -emit-module-interface -o %t/c.pcm |
| 10 |
// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -fmodule-file=c=%t/c.pcm -o %t/d.pcm |
| 11 |
// RUN: %clang_cc1 -std=c++20 %t/e.cpp -fmodule-file=d=%t/d.pcm -fmodule-file=c=%t/c.pcm -verify -fsyntax-only |
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-module-interface -fmodule-file=c=%t/c.pcm -o %t/f.pcm |
| 13 |
// RUN: %clang_cc1 -std=c++20 %t/g.cpp -fmodule-file=f=%t/f.pcm -fmodule-file=c=%t/c.pcm -verify -fsyntax-only |
| 14 |
|
| 15 |
// Test again with reduced BMI |
| 16 |
// RUN: rm -rf %t |
| 17 |
// RUN: mkdir -p %t |
| 18 |
// RUN: split-file %s %t |
| 19 |
// |
| 20 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -I%t -emit-reduced-module-interface -o %t/a.pcm |
| 21 |
// RUN: %clang_cc1 -std=c++20 %t/b.cpp -fmodule-file=a=%t/a.pcm -verify -fsyntax-only |
| 22 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -I%t -emit-reduced-module-interface -o %t/c.pcm |
| 23 |
// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-reduced-module-interface -fmodule-file=c=%t/c.pcm -o %t/d.pcm |
| 24 |
// RUN: %clang_cc1 -std=c++20 %t/e.cpp -fmodule-file=d=%t/d.pcm -fmodule-file=c=%t/c.pcm -verify -fsyntax-only |
| 25 |
// RUN: %clang_cc1 -std=c++20 %t/f.cppm -emit-reduced-module-interface -fmodule-file=c=%t/c.pcm -o %t/f.pcm |
| 26 |
// RUN: %clang_cc1 -std=c++20 %t/g.cpp -fmodule-file=f=%t/f.pcm -fmodule-file=c=%t/c.pcm -verify -fsyntax-only |
| 27 |
|
| 28 |
//--- initializer_list.h |
| 29 |
namespace std { |
| 30 |
typedef decltype(sizeof(int)) size_t; |
| 31 |
template<typename T> struct initializer_list { |
| 32 |
const T* ptr; size_t sz; |
| 33 |
initializer_list(const T *, size_t); |
| 34 |
const T* begin(); |
| 35 |
const T* end(); |
| 36 |
}; |
| 37 |
} |
| 38 |
|
| 39 |
//--- a.cppm |
| 40 |
module; |
| 41 |
#include "initializer_list.h" |
| 42 |
export module a; |
| 43 |
export template<typename> |
| 44 |
void a() { |
| 45 |
for (int x : {0}) { |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
//--- b.cpp |
| 50 |
// expected-no-diagnostics |
| 51 |
import a; |
| 52 |
void b() { |
| 53 |
a<int>(); |
| 54 |
} |
| 55 |
|
| 56 |
//--- c.cppm |
| 57 |
module; |
| 58 |
#include "initializer_list.h" |
| 59 |
export module c; |
| 60 |
namespace std { |
| 61 |
export using std::initializer_list; |
| 62 |
} |
| 63 |
|
| 64 |
//--- d.cppm |
| 65 |
export module d; |
| 66 |
import c; |
| 67 |
export template<typename> |
| 68 |
void d() { |
| 69 |
for (int x : {0}) { |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
//--- e.cpp |
| 74 |
import d; |
| 75 |
void e() { |
| 76 |
for (int x : {0}) { // expected-error {{cannot deduce type of initializer list because std::initializer_list was not found; include <initializer_list>}} |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
template <typename> |
| 81 |
void ee() { |
| 82 |
for (int x : {0}) { // expected-error {{cannot deduce type of initializer list because std::initializer_list was not found; include <initializer_list>}} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
void eee() { |
| 87 |
ee<int>(); |
| 88 |
d<int>(); |
| 89 |
} |
| 90 |
|
| 91 |
//--- f.cppm |
| 92 |
export module f; |
| 93 |
export import c; |
| 94 |
|
| 95 |
//--- g.cpp |
| 96 |
// expected-no-diagnostics |
| 97 |
import f; |
| 98 |
void g() { |
| 99 |
for (int x : {0}) { |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
template <typename> |
| 104 |
void gg() { |
| 105 |
for (int x : {0}) { |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
void ggg() { |
| 110 |
gg<int>(); |
| 111 |
} |