1 // RUN: rm -rf %t 2 // RUN: mkdir %t 3 // RUN: split-file %s %t 4 // 5 // RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \ 6 // RUN: -emit-module %t/modules.map \ 7 // RUN: -o %t/module.pcm 8 // 9 // 10 // RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-file=%t/module.pcm \ 11 // RUN: -fmodule-map-file=%t/modules.map \ 12 // RUN: -fsyntax-only -verify %t/use.cpp 13 // 14 //--- use.cpp 15 // expected-no-diagnostics 16 17 #include "concepts.h" 18 #include "format.h" 19 foo()20template <class T> void foo() 21 requires same_as<T, T> 22 {} 23 24 //--- modules.map 25 module "library" { 26 export * 27 module "concepts" { 28 export * 29 header "concepts.h" 30 } 31 module "compare" { 32 export * 33 header "compare.h" 34 } 35 module "format" { 36 export * 37 header "format.h" 38 } 39 } 40 41 //--- concepts.h 42 #ifndef SAMEAS_CONCEPTS_H_ 43 #define SAMEAS_CONCEPTS_H_ 44 45 #include "same_as.h" 46 47 #endif // SAMEAS_CONCEPTS_H 48 49 //--- same_as.h 50 #ifndef SAME_AS_H 51 #define SAME_AS_H 52 53 template <class T, class U> 54 concept same_as_impl = __is_same(T, U); 55 56 template <class T, class U> 57 concept same_as = same_as_impl<T, U> && same_as_impl<U, T>; 58 #endif // SAME_AS_H 59 60 61 //--- compare.h 62 #ifndef COMPARE_H 63 #define COMPARE_H 64 65 #include "same_as.h" 66 #include "concepts.h" 67 foo()68template <class T> void foo() 69 requires same_as<T, int> 70 {} 71 #endif // COMPARE_H 72 73 //--- format.h 74 #ifndef FORMAT_H 75 #define FORMAT_H 76 77 #include "same_as.h" 78 #include "concepts.h" 79 bar()80template <class T> void bar() 81 requires same_as<T, int> 82 {} 83 84 #endif // FORMAT_H 85