| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: cd %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/A-B.cppm -I%t -emit-module-interface -o %t/A-B.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/A-C.cppm -I%t -emit-module-interface -o %t/A-C.pcm |
| 7 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/A.pcm |
| 8 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only |
| 9 |
|
| 10 |
// Test again with reduced BMI. |
| 11 |
// |
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/A-B.cppm -I%t -emit-reduced-module-interface -o %t/A-B.pcm |
| 13 |
// RUN: %clang_cc1 -std=c++20 %t/A-C.cppm -I%t -emit-reduced-module-interface -o %t/A-C.pcm |
| 14 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -fprebuilt-module-path=%t -o %t/A.pcm |
| 15 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only |
| 16 |
|
| 17 |
|
| 18 |
//--- foo.h |
| 19 |
template <typename U, typename T> |
| 20 |
class pair {}; |
| 21 |
|
| 22 |
template <typename U> |
| 23 |
class allocator {}; |
| 24 |
|
| 25 |
template <typename T> |
| 26 |
class my_traits {}; |
| 27 |
|
| 28 |
template <class _Key, class _Tp, |
| 29 |
class _Alloc = allocator<pair<const _Key, _Tp> > > |
| 30 |
class unordered_map |
| 31 |
{ |
| 32 |
public: |
| 33 |
unordered_map() {} |
| 34 |
}; |
| 35 |
|
| 36 |
template<bool, class = void> struct my_enable_if {}; |
| 37 |
template<class T> struct my_enable_if<true, T> { using type = T; }; |
| 38 |
template<bool B, class T = void> using my_enable_if_t = typename my_enable_if<B, T>::type; |
| 39 |
|
| 40 |
template<class _InputIterator, |
| 41 |
class _Allocator = allocator<my_traits<_InputIterator>>, |
| 42 |
class = my_enable_if_t<_InputIterator::value>> |
| 43 |
unordered_map(_InputIterator, _InputIterator, _Allocator = _Allocator()) |
| 44 |
-> unordered_map<my_traits<_InputIterator>, my_traits<_InputIterator>, _Allocator>; |
| 45 |
|
| 46 |
template <class _CharT, |
| 47 |
class _Traits = my_traits<_CharT>, |
| 48 |
class _Allocator = allocator<_CharT> > |
| 49 |
class basic_string; |
| 50 |
typedef basic_string<char, my_traits<char>, allocator<char> > string; |
| 51 |
|
| 52 |
template<class _CharT, class _Traits, class _Allocator> |
| 53 |
class basic_string |
| 54 |
{ |
| 55 |
public: |
| 56 |
basic_string(); |
| 57 |
|
| 58 |
template<class _InputIterator, class = my_enable_if_t<_InputIterator::value> > |
| 59 |
basic_string(_InputIterator __first, _InputIterator __last, const _Allocator& __a); |
| 60 |
|
| 61 |
void resize(unsigned __n, _CharT __c); |
| 62 |
}; |
| 63 |
|
| 64 |
extern template void basic_string<char>::resize(unsigned, char); |
| 65 |
|
| 66 |
//--- A-B.cppm |
| 67 |
module; |
| 68 |
#include "foo.h" |
| 69 |
export module A:B; |
| 70 |
export using ::string; |
| 71 |
|
| 72 |
//--- A-C.cppm |
| 73 |
module; |
| 74 |
#include "foo.h" |
| 75 |
export module A:C; |
| 76 |
|
| 77 |
//--- A.cppm |
| 78 |
export module A; |
| 79 |
export import :B; |
| 80 |
export import :C; |
| 81 |
|
| 82 |
//--- Use.cpp |
| 83 |
import A; |
| 84 |
string s; |
| 85 |
::unordered_map<int, int> mime_map; // expected-error {{missing '#include'; 'unordered_map' must be declared before it is used}} |
| 86 |
// expected-note@* {{declaration here is not visible}} |