[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / merge-concepts.cpp
blobc774157dd85b4e56469ef4eedf04bebdb21a53dc
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
14 //--- use.cpp
15 // expected-no-diagnostics
17 #include "concepts.h"
18 #include "format.h"
20 template <class T> void foo()
21 requires same_as<T, T>
24 //--- modules.map
25 module "library" {
26 export *
27 module "concepts" {
28 export *
29 header "concepts.h"
31 module "compare" {
32 export *
33 header "compare.h"
35 module "format" {
36 export *
37 header "format.h"
41 //--- concepts.h
42 #ifndef SAMEAS_CONCEPTS_H_
43 #define SAMEAS_CONCEPTS_H_
45 #include "same_as.h"
47 #endif // SAMEAS_CONCEPTS_H
49 //--- same_as.h
50 #ifndef SAME_AS_H
51 #define SAME_AS_H
53 template <class T, class U>
54 concept same_as_impl = __is_same(T, U);
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
61 //--- compare.h
62 #ifndef COMPARE_H
63 #define COMPARE_H
65 #include "same_as.h"
66 #include "concepts.h"
68 template <class T> void foo()
69 requires same_as<T, int>
71 #endif // COMPARE_H
73 //--- format.h
74 #ifndef FORMAT_H
75 #define FORMAT_H
77 #include "same_as.h"
78 #include "concepts.h"
80 template <class T> void bar()
81 requires same_as<T, int>
84 #endif // FORMAT_H