[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / merge-concepts-cxx-modules.cpp
blob0127e8baad6b94a230c3154353e9777de6a6f182
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/same_as.cppm -o %t/same_as.pcm
6 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/concepts.cppm -o %t/concepts.pcm
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/format.cppm -o %t/format.pcm
8 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/conflicting.cppm -o %t/conflicting.pcm
9 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cppm -fsyntax-only -verify
11 // Test again with reduced BMI.
12 // RUN: rm -rf %t
13 // RUN: mkdir %t
14 // RUN: split-file %s %t
16 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/same_as.cppm -o %t/same_as.pcm
17 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/concepts.cppm -o %t/concepts.pcm
18 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/format.cppm -o %t/format.pcm
19 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/conflicting.cppm -o %t/conflicting.pcm
20 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cppm -fsyntax-only -verify
23 //--- same_as.cppm
24 export module same_as;
25 export template <class T, class U>
26 concept same_as = __is_same(T, U);
28 //--- concepts.cppm
29 export module concepts;
30 export import same_as;
32 export template <class T>
33 concept ConflictingConcept = true;
35 //--- format.cppm
37 export module format;
38 export import concepts;
39 export import same_as;
41 export template <class T> void foo()
42 requires same_as<T, int>
45 //--- conflicting.cppm
46 export module conflicting;
47 export template <class T, class U = int>
48 concept ConflictingConcept = true;
50 //--- Use.cppm
51 import format;
52 import conflicting;
54 template <class T> void foo()
55 requires same_as<T, T>
57 ConflictingConcept auto x = 10; // expected-error {{reference to 'ConflictingConcept' is ambiguous}}
58 // expected-note@* 2 {{candidate}}