Jonas Hahnfeld | 99b5474 | 2023-08-01 18:31:51 +0200 | [diff] [blame] | 1 | // RUN: rm -rf %t |
| 2 | // RUN: mkdir %t |
| 3 | // RUN: split-file %s %t |
| 4 | |
| 5 | // RUN: %clang_cc1 -emit-obj -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %t/merge.cpp -o %t/merge.o |
| 6 | |
| 7 | //--- V.h |
| 8 | #ifndef V_H |
| 9 | #define V_H |
| 10 | template <typename T> |
| 11 | struct V { |
| 12 | ~V() {} |
| 13 | }; |
| 14 | #endif |
| 15 | |
| 16 | //--- A.h |
| 17 | #include "V.h" |
| 18 | |
| 19 | void A(const V<unsigned long> &v); |
| 20 | |
| 21 | //--- B.h |
| 22 | #include "V.h" |
| 23 | |
| 24 | inline V<unsigned long> B() { |
| 25 | return {}; |
| 26 | } |
| 27 | |
| 28 | //--- C.h |
| 29 | #include "V.h" |
| 30 | |
| 31 | #include "A.h" |
| 32 | |
| 33 | class C { |
| 34 | public: |
| 35 | C(const V<unsigned long> &v) { |
| 36 | V<unsigned long> v2; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | C GetC() { |
| 41 | return {{}}; |
| 42 | } |
| 43 | |
| 44 | // This include *MUST* come last. |
| 45 | #include "B.h" |
| 46 | |
| 47 | //--- module.modulemap |
| 48 | module "V" { header "V.h" export * } |
| 49 | module "A" { header "A.h" export * } |
| 50 | module "B" { header "B.h" export * } |
| 51 | module "C" { header "C.h" export * } |
| 52 | |
| 53 | //--- merge.cpp |
| 54 | #include "C.h" |
| 55 | |
| 56 | template <typename T> |
| 57 | C GetC_main() { |
| 58 | return {{}}; |
| 59 | } |
| 60 | |
| 61 | void f() { |
| 62 | GetC_main<float>(); |
| 63 | GetC(); |
| 64 | } |