| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \ |
| 7 |
// RUN: -fprebuilt-module-path=%t |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -o %t/c.pcm \ |
| 9 |
// RUN: -fprebuilt-module-path=%t |
| 10 |
// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -o %t/d.pcm \ |
| 11 |
// RUN: -fprebuilt-module-path=%t |
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/e.cpp -fsyntax-only -verify -fprebuilt-module-path=%t |
| 13 |
|
| 14 |
// Test again with reduced BMI |
| 15 |
// RUN: rm -rf %t |
| 16 |
// RUN: mkdir -p %t |
| 17 |
// RUN: split-file %s %t |
| 18 |
// |
| 19 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm |
| 20 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm \ |
| 21 |
// RUN: -fprebuilt-module-path=%t |
| 22 |
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface -o %t/c.pcm \ |
| 23 |
// RUN: -fprebuilt-module-path=%t |
| 24 |
// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-reduced-module-interface -o %t/d.pcm \ |
| 25 |
// RUN: -fprebuilt-module-path=%t |
| 26 |
// RUN: %clang_cc1 -std=c++20 %t/e.cpp -fsyntax-only -verify -fprebuilt-module-path=%t |
| 27 |
|
| 28 |
|
| 29 |
//--- a.cppm |
| 30 |
export module a; |
| 31 |
|
| 32 |
struct WithCtor { |
| 33 |
WithCtor(); |
| 34 |
}; |
| 35 |
|
| 36 |
export template <typename T> |
| 37 |
struct Getter { |
| 38 |
union { |
| 39 |
WithCtor container; |
| 40 |
}; |
| 41 |
}; |
| 42 |
|
| 43 |
//--- b.cppm |
| 44 |
export module b; |
| 45 |
|
| 46 |
import a; |
| 47 |
|
| 48 |
export template <typename T> |
| 49 |
class AnySpan { |
| 50 |
public: |
| 51 |
AnySpan(); |
| 52 |
AnySpan(Getter<T> getter) |
| 53 |
: getter_(getter) {} |
| 54 |
|
| 55 |
private: |
| 56 |
Getter<T> getter_; |
| 57 |
}; |
| 58 |
|
| 59 |
//--- c.cppm |
| 60 |
export module c; |
| 61 |
import b; |
| 62 |
|
| 63 |
export inline void RegisterInt322( |
| 64 |
AnySpan<const int> sibling_field_nums) { |
| 65 |
sibling_field_nums = sibling_field_nums; |
| 66 |
} |
| 67 |
|
| 68 |
//--- d.cppm |
| 69 |
// expected-no-diagnostics |
| 70 |
export module d; |
| 71 |
import c; |
| 72 |
import b; |
| 73 |
|
| 74 |
export inline void RegisterInt32( |
| 75 |
AnySpan<const int> sibling_field_nums = {}) { |
| 76 |
sibling_field_nums = sibling_field_nums; |
| 77 |
} |
| 78 |
|
| 79 |
//--- e.cpp |
| 80 |
import d; |
| 81 |
import b; |
| 82 |
|
| 83 |
// expected-no-diagnostics |
| 84 |
void foo(AnySpan<const int> s) { |
| 85 |
s = AnySpan<const int>(s); |
| 86 |
} |