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//--- foo.h
11template <typename U, typename T>
12class pair {};
13
14template <typename U>
15class allocator {};
16
17template <typename T>
18class my_traits {};
19
20template <class _Key, class _Tp,
21          class _Alloc = allocator<pair<const _Key, _Tp> > >
22class unordered_map
23{
24public:
25    unordered_map() {}
26};
27
28template<bool, class = void> struct my_enable_if {};
29template<class T> struct my_enable_if<true, T> { using type = T; };
30template<bool B, class T = void> using my_enable_if_t = typename my_enable_if<B, T>::type;
31
32template<class _InputIterator,
33         class _Allocator = allocator<my_traits<_InputIterator>>,
34         class = my_enable_if_t<_InputIterator::value>>
35unordered_map(_InputIterator, _InputIterator, _Allocator = _Allocator())
36  -> unordered_map<my_traits<_InputIterator>, my_traits<_InputIterator>, _Allocator>;
37
38template <class _CharT,
39          class _Traits = my_traits<_CharT>,
40          class _Allocator = allocator<_CharT> >
41    class basic_string;
42typedef basic_string<char, my_traits<char>, allocator<char> > string;
43
44template<class _CharT, class _Traits, class _Allocator>
45class basic_string
46{
47public:
48    basic_string();
49
50    template<class _InputIterator, class = my_enable_if_t<_InputIterator::value> >
51            basic_string(_InputIterator __first, _InputIterator __last, const _Allocator& __a);
52
53    void resize(unsigned __n, _CharT __c);
54};
55
56extern template void basic_string<char>::resize(unsigned, char);
57
58//--- A-B.cppm
59module;
60#include "foo.h"
61export module A:B;
62export using ::string;
63
64//--- A-C.cppm
65module;
66#include "foo.h"
67export module A:C;
68
69//--- A.cppm
70export module A;
71export import :B;
72export import :C;
73
74//--- Use.cpp
75import A;
76string s;
77::unordered_map<int, int> mime_map; // expected-error {{missing '#include'; 'unordered_map' must be declared before it is used}}
78                                    // expected-note@* {{declaration here is not visible}}
79