[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / compare-modules-cxx2a.cpp
blob19093b89f60cf731eaea7ee00e777a0d3320eff9
1 // RUN: rm -rf %t.mcp
2 // RUN: mkdir -p %t
4 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery -fmodule-map-file=%S/Inputs/compare.modulemap
5 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fmodules-cache-path=%t.mcp -I%S/Inputs %s -fno-modules-error-recovery -fmodule-map-file=%S/Inputs/compare.modulemap -fexperimental-new-constant-interpreter
7 struct CC { CC(...); };
9 void a() { void(0 <=> 0); } // expected-error {{include <compare>}}
11 struct A {
12 CC operator<=>(const A&) const = default; // expected-error {{include <compare>}}
14 auto va = A() <=> A(); // expected-note {{required here}}
16 #pragma clang module import compare.other
18 // expected-note@std-compare.h:* 2+{{not reachable}}
20 void b() { void(0 <=> 0); } // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
22 struct B {
23 CC operator<=>(const B&) const = default; // expected-error 1+{{definition of 'strong_ordering' must be imported from module 'compare.cmp' before it is required}}
25 auto vb = B() <=> B(); // expected-note {{required here}}
27 #pragma clang module import compare.cmp
29 void c() { void(0 <=> 0); }
31 struct C {
32 CC operator<=>(const C&) const = default;
34 auto vc = C() <=> C();
37 #pragma clang module build compare2
38 module compare2 {}
39 #pragma clang module contents
40 #pragma clang module begin compare2
41 #include "std-compare.h"
42 #pragma clang module end
43 #pragma clang module endbuild
45 #pragma clang module import compare2
47 void g() { void(0.0 <=> 0.0); }