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 19template <typename U, typename T> 20class pair {}; 21 22template <typename U> 23class allocator {}; 24 25template <typename T> 26class my_traits {}; 27 28template <class _Key, class _Tp, 29 class _Alloc = allocator<pair<const _Key, _Tp> > > 30class unordered_map 31{ 32public: 33 unordered_map() {} 34}; 35 36template<bool, class = void> struct my_enable_if {}; 37template<class T> struct my_enable_if<true, T> { using type = T; }; 38template<bool B, class T = void> using my_enable_if_t = typename my_enable_if<B, T>::type; 39 40template<class _InputIterator, 41 class _Allocator = allocator<my_traits<_InputIterator>>, 42 class = my_enable_if_t<_InputIterator::value>> 43unordered_map(_InputIterator, _InputIterator, _Allocator = _Allocator()) 44 -> unordered_map<my_traits<_InputIterator>, my_traits<_InputIterator>, _Allocator>; 45 46template <class _CharT, 47 class _Traits = my_traits<_CharT>, 48 class _Allocator = allocator<_CharT> > 49 class basic_string; 50typedef basic_string<char, my_traits<char>, allocator<char> > string; 51 52template<class _CharT, class _Traits, class _Allocator> 53class basic_string 54{ 55public: 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 64extern template void basic_string<char>::resize(unsigned, char); 65 66//--- A-B.cppm 67module; 68#include "foo.h" 69export module A:B; 70export using ::string; 71 72//--- A-C.cppm 73module; 74#include "foo.h" 75export module A:C; 76 77//--- A.cppm 78export module A; 79export import :B; 80export import :C; 81 82//--- Use.cpp 83import A; 84string 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}} 87